From 24f3e9c2408dd3b6bd59b37b6ac4fb3ef3f23e00 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Tue, 28 Nov 2017 15:02:54 +0100 Subject: [PATCH] Added mayah_c12. --- src/mayah_c12/baseinfo.ini | 7 ++++ src/mayah_c12/checks/mayah_c12_fan | 39 +++++++++++++++++ src/mayah_c12/checks/mayah_c12_temp | 42 +++++++++++++++++++ .../web/plugins/perfometer/mayah_c12_fan.py | 34 +++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 src/mayah_c12/baseinfo.ini create mode 100644 src/mayah_c12/checks/mayah_c12_fan create mode 100644 src/mayah_c12/checks/mayah_c12_temp create mode 100644 src/mayah_c12/web/plugins/perfometer/mayah_c12_fan.py diff --git a/src/mayah_c12/baseinfo.ini b/src/mayah_c12/baseinfo.ini new file mode 100644 index 0000000..d25af78 --- /dev/null +++ b/src/mayah_c12/baseinfo.ini @@ -0,0 +1,7 @@ +[info] +title = Mayah C12 SNMP Checks +author = Markus Birth +description = SNMP based checks (fans, temperature) for the Mayah C12 IP/ISDN audio codec. +version = 2017.02.07.1 +version.min_required = 1.2.8p2 +download_url = https://github.com/mbirth/check_mk-plugins diff --git a/src/mayah_c12/checks/mayah_c12_fan b/src/mayah_c12/checks/mayah_c12_fan new file mode 100644 index 0000000..dc78962 --- /dev/null +++ b/src/mayah_c12/checks/mayah_c12_fan @@ -0,0 +1,39 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +mayah_c12_fan_default_levels = { "lower": (1000, 300) } + +def inventory_mayah_c12_fan(info): + inventory = [] + inventory.append( ("Case", "mayah_c12_fan_default_levels") ) + return inventory + +def check_mayah_c12_fan(item, params, info): + hexdata = info[0][0] + + if item == "Case": + rpm = int(hexdata[10:12], 16) * 100 + else: + return (3, "Invalid item: %s" % item) + + return check_fan(rpm, params) + +check_info["mayah_c12_fan"] = { + "check_function" : check_mayah_c12_fan, + "inventory_function" : inventory_mayah_c12_fan, + "group" : "hw_fans", + "service_description" : "%s Fan", + "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" : [ "fan.include" ], + "has_perfdata" : True +} diff --git a/src/mayah_c12/checks/mayah_c12_temp b/src/mayah_c12/checks/mayah_c12_temp new file mode 100644 index 0000000..20e9a1d --- /dev/null +++ b/src/mayah_c12/checks/mayah_c12_temp @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +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 +} diff --git a/src/mayah_c12/web/plugins/perfometer/mayah_c12_fan.py b/src/mayah_c12/web/plugins/perfometer/mayah_c12_fan.py new file mode 100644 index 0000000..3adc4b7 --- /dev/null +++ b/src/mayah_c12/web/plugins/perfometer/mayah_c12_fan.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8; py-indent-offset: 4 -*- +# _______ __ _ ____ __ +# | | \ | |___ \ / / +# | | \| | __) | / /-,_ +# | | |\ |/ __/ /__ _| +# |_______|_| \__|_____| |_| +# +# @author Markus Birth + +def perfometer_mayah_c12_fan(row, check_command, perfdata): + if len(perfdata) < 1: + return "", "" + + rpm = float(perfdata[0][1]) + if perfdata[0][3]: + warn = float(perfdata[0][3]) + else: + warn = 7000 + if perfdata[0][4]: + crit = float(perfdata[0][4]) + else: + crit = 8500 + + if rpm >= crit: + color = "#d23" + elif rpm >= warn: + color = "#dd2" + else: + color = "#2d3" + + return "%i rpm" % rpm, perfometer_linear(100*rpm/crit, color) + +perfometers["check_mk-mayah_c12_fan"] = perfometer_mayah_c12_fan