#!/usr/bin/python
# -*- coding: utf-8; py-indent-offset: 4 -*-
#  _______ __   _ ____     __
# |       |  \ | |___ \   / /
# |       |   \| | __) | / /-,_
# |       | |\   |/ __/ /__   _|
# |_______|_| \__|_____|   |_|
#
# @author Markus Birth <markus.birth@weltn24.de>

mayah_c12_temp_default_levels = { "levels": (45, 60) }

def inventory_mayah_c12_temp(info):
    inventory = []
    inventory.append( ("CPU", "mayah_c12_temp_default_levels") )
    inventory.append( ("Case", "mayah_c12_temp_default_levels") )
    return inventory

def check_mayah_c12_temp(item, params, info):
    hexdata = info[0][0]

    if item == "CPU":
        temp = int(hexdata[6:8], 16)
    elif item == "Case":
        temp = int(hexdata[4:6], 16)
    else:
        return (3, "Invalid item: %s" % item)

    return check_temperature(temp, params, item)

check_info["mayah_c12_temp"] = {
    "check_function"        : check_mayah_c12_temp,
    "inventory_function"    : inventory_mayah_c12_temp,
    "group"                 : "temperature",
    "service_description"   : "%s Temperature",
    "snmp_info"             : (".1.3.6.1.4.1.6210.1", [
                                     6,  # syshealth1
                              ]),
    "snmp_scan_function"    : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.6210"),
    "includes"              : [ "temperature.include" ],
    "has_perfdata"          : True
}
