diff --git a/src/lynx_rct5023g/baseinfo.ini b/src/lynx_rct5023g/baseinfo.ini new file mode 100644 index 0000000..3a7c8de --- /dev/null +++ b/src/lynx_rct5023g/baseinfo.ini @@ -0,0 +1,7 @@ +[info] +title = Lynx RCT5023g frame controller +author = Markus Birth +description = SNMP based checks (fans, PSUs, system status) for the Lynx RCT5023g frame controller. +version = 2016.07.06.1 +version.min_required = 1.2.8p2 +download_url = https://github.com/mbirth/check_mk-plugins diff --git a/src/lynx_rct5023g/checks/lynx_rct5023g_fan b/src/lynx_rct5023g/checks/lynx_rct5023g_fan new file mode 100644 index 0000000..22834b9 --- /dev/null +++ b/src/lynx_rct5023g/checks/lynx_rct5023g_fan @@ -0,0 +1,59 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +def inventory_lynx_rct5023g_fan(info): + inventory = [] + for OID_END, name, label, f1name, f2name, f3name, f1stat, f2stat, f3stat in info: + inventory.append( (name, None) ) + return inventory + +def check_lynx_rct5023g_fan(item, _no_params, info): + states = [ "ok", "fail", "missing" ] + status = 0 + for OID_END, name, label, f1name, f2name, f3name, f1stat, f2stat, f3stat in info: + if item != name: + continue + + f1stat = states[int(f1stat)] + f2stat = states[int(f2stat)] + f3stat = states[int(f3stat)] + + if "fail" in f1stat+f2stat+f3stat: + status = 2 + elif not "ok" in f1stat+f2stat+f3stat: + status = 1 + + message = u"%s, ❃1:%s, ❃2:%s, ❃3:%s" % (label, f1stat, f2stat, f3stat) + message += u"\r\n1: %s" % (f1name) + message += u"\r\n2: %s" % (f2name) + message += u"\r\n3: %s" % (f3name) + + return status, message + + return 3, "%s not found in SNMP data." % item + +check_info["lynx_rct5023g_fan"] = { + "check_function" : check_lynx_rct5023g_fan, + "inventory_function" : inventory_lynx_rct5023g_fan, + "service_description" : "%s Fans", + "snmp_info" : (".1.3.6.1.4.1.14755.2", ["49672.644.1.1", "49673.644.1.1"], [ + OID_END, + 1, # Device name + 2, # Custom name + 38, # fan1Name + 39, # fan2Name + 40, # fan3Name + 41, # fan1Status + 42, # fan2Status + 43, # fan3Status + ]), + "snmp_scan_function" : lambda oid: oid(".1.3.6.1.4.1.14755.2.49672.*"), + "has_perfdata" : False +} diff --git a/src/lynx_rct5023g/checks/lynx_rct5023g_power b/src/lynx_rct5023g/checks/lynx_rct5023g_power new file mode 100644 index 0000000..bc72c91 --- /dev/null +++ b/src/lynx_rct5023g/checks/lynx_rct5023g_power @@ -0,0 +1,64 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +def inventory_lynx_rct5023g_power(info): + inventory = [] + for OID_END, name, label, p1name, p1stat, p1volt, p1temp, p2name, p2stat, p2volt, p2temp in info: + inventory.append( (name, None) ) + return inventory + +def check_lynx_rct5023g_power(item, _no_params, info): + status = 0 + for OID_END, name, label, p1name, p1stat, p1volt, p1temp, p2name, p2stat, p2volt, p2temp in info: + if item != name: + continue + + p1volt = savefloat(p1volt)/10 + p1temp = saveint(p1temp) + p2volt = savefloat(p2volt)/10 + p2temp = saveint(p2temp) + + if p1stat != "" or p2stat != "": + status = 2 + + if p1stat == "": + p1stat = "OK" + + if p2stat == "": + p2stat = "OK" + + message = u"%s, ⚡1:%s (%.1fV, %s℃), ⚡2:%s (%.1fV, %s℃)" % (label, p1stat, p1volt, p1temp, p2stat, p2volt, p2temp) + message += u"\r\n1: %s" % (p1name) + message += u"\r\n2: %s" % (p2name) + + return status, message + + return 3, "%s not found in SNMP data." % item + +check_info["lynx_rct5023g_power"] = { + "check_function" : check_lynx_rct5023g_power, + "inventory_function" : inventory_lynx_rct5023g_power, + "service_description" : "%s PSU", + "snmp_info" : (".1.3.6.1.4.1.14755.2", ["49672.644.1.1", "49673.644.1.1"], [ + OID_END, + 1, # Device name + 2, # Custom name + 18, # psu1Name + 19, # psu1Status + 20, # psu1Voltage + 21, # psu1Temp + 22, # psu2Name + 23, # psu2Status + 24, # psu2Voltage + 25, # psu2Temp + ]), + "snmp_scan_function" : lambda oid: oid(".1.3.6.1.4.1.14755.2.49672.*"), + "has_perfdata" : False +} diff --git a/src/lynx_rct5023g/checks/lynx_rct5023g_state b/src/lynx_rct5023g/checks/lynx_rct5023g_state new file mode 100644 index 0000000..0086974 --- /dev/null +++ b/src/lynx_rct5023g/checks/lynx_rct5023g_state @@ -0,0 +1,53 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +def inventory_lynx_rct5023g_state(info): + inventory = [] + for OID_END, name, label, color, text in info: + inventory.append( (name, None) ) + return inventory + +def check_lynx_rct5023g_state(item, _no_params, info): + ledColors = [ "unknown", "black", "green", "yellow", "red" ] + status = 0 + for OID_END, name, label, color, text in info: + if item != name: + continue + + color = int(color) + colorname = ledColors[color] + + if colorname == "yellow": + status = 1 + elif colorname == "red" or colorname == "black": + status = 2 + elif colorname == "unknown": + status = 3 + + message = "%s, LED:%s, Status:%s" % (label, colorname, text) + + return status, message + + return 3, "%s not found in SNMP data." % item + +check_info["lynx_rct5023g_state"] = { + "check_function" : check_lynx_rct5023g_state, + "inventory_function" : inventory_lynx_rct5023g_state, + "service_description" : "%s Status", + "snmp_info" : (".1.3.6.1.4.1.14755.2", ["49672.644.1.1", "49673.644.1.1"], [ + OID_END, + 1, # Device name + 2, # Custom name + 7, # statusColor + 9, # statusText + ]), + "snmp_scan_function" : lambda oid: oid(".1.3.6.1.4.1.14755.2.49672.*"), + "has_perfdata" : False +} diff --git a/src/lynx_rct5023g/web/htdocs/images/icons/Lynx.png b/src/lynx_rct5023g/web/htdocs/images/icons/Lynx.png new file mode 100644 index 0000000..f062611 Binary files /dev/null and b/src/lynx_rct5023g/web/htdocs/images/icons/Lynx.png differ