From 0aa461839bc561788ac1ff3a2ba99c9b03730c6e Mon Sep 17 00:00:00 2001 From: George Pochiscan Date: Tue, 27 Jun 2023 18:37:41 +0300 Subject: [PATCH] added checkmk checks for clever_pdu with firmware 1.2.0 and 1.3.0 --- check_mk-clever-pdu/cmk1.6/README | 20 +++ .../cmk1.6/clever_pdu_1-6-1.1.mkp | Bin 0 -> 3508 bytes .../local/share/check_mk/checkman/clever_pdu | 13 ++ .../check_mk/checkman/clever_pdu_humidity | 13 ++ .../share/check_mk/checkman/clever_pdu_temp | 13 ++ .../share/check_mk/checks/clever_pdu_120 | 129 ++++++++++++++++++ .../share/check_mk/checks/clever_pdu_130 | 127 +++++++++++++++++ .../check_mk/checks/clever_pdu_humidity_120 | 49 +++++++ .../check_mk/checks/clever_pdu_humidity_130 | 49 +++++++ .../share/check_mk/checks/clever_pdu_temp_120 | 49 +++++++ .../share/check_mk/checks/clever_pdu_temp_130 | 49 +++++++ .../check_mk/web/plugins/wato/clever_pdu.py | 83 +++++++++++ check_mk-clever-pdu/cmk2/checkman/clever_pdu | 13 ++ .../cmk2/checkman/clever_pdu_humidity | 13 ++ .../cmk2/checkman/clever_pdu_temp | 13 ++ .../cmk2/clever_pdu_2-1.0.1.mkp | Bin 0 -> 3733 bytes check_mk-clever-pdu/cmk2/info | 20 +++ .../plugins/agent_based/clever_pdu_120.py | 126 +++++++++++++++++ .../plugins/agent_based/clever_pdu_130.py | 125 +++++++++++++++++ .../agent_based/clever_pdu_humidity_120.py | 64 +++++++++ .../agent_based/clever_pdu_humidity_130.py | 64 +++++++++ .../agent_based/clever_pdu_temp_120.py | 69 ++++++++++ .../agent_based/clever_pdu_temp_130.py | 69 ++++++++++ .../plugins/agent_based/utils/humidity.py | 33 +++++ .../cmk2/plugins/wato/clever_pdu.py | 65 +++++++++ 25 files changed, 1268 insertions(+) create mode 100644 check_mk-clever-pdu/cmk1.6/README create mode 100644 check_mk-clever-pdu/cmk1.6/clever_pdu_1-6-1.1.mkp create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_humidity create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_temp create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_120 create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_130 create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_120 create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_130 create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_120 create mode 100644 check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_130 create mode 100755 check_mk-clever-pdu/cmk1.6/local/share/check_mk/web/plugins/wato/clever_pdu.py create mode 100644 check_mk-clever-pdu/cmk2/checkman/clever_pdu create mode 100644 check_mk-clever-pdu/cmk2/checkman/clever_pdu_humidity create mode 100644 check_mk-clever-pdu/cmk2/checkman/clever_pdu_temp create mode 100644 check_mk-clever-pdu/cmk2/clever_pdu_2-1.0.1.mkp create mode 100644 check_mk-clever-pdu/cmk2/info create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_120.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_130.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_120.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_130.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_120.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_130.py create mode 100644 check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/utils/humidity.py create mode 100644 check_mk-clever-pdu/cmk2/plugins/wato/clever_pdu.py diff --git a/check_mk-clever-pdu/cmk1.6/README b/check_mk-clever-pdu/cmk1.6/README new file mode 100644 index 0000000..e21b745 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/README @@ -0,0 +1,20 @@ +{'author': u'George Pochiscan', + 'description': u'', + 'download_url': '', + 'files': {'checkman': ['clever_pdu', + 'clever_pdu_humidity', + 'clever_pdu_temp'], + 'checks': ['clever_pdu_120', + 'clever_pdu_130', + 'clever_pdu_humidity_120', + 'clever_pdu_humidity_130', + 'clever_pdu_temp_120', + 'clever_pdu_temp_130'], + 'web': ['plugins/wato/clever_pdu.py']}, + 'name': 'clever_pdu_1-6', + 'num_files': 10, + 'title': u'Clever PDU checks for Checkmk 1.6', + 'version': '1.1', + 'version.min_required': '1.6.0p20', + 'version.packaged': '1.6.0p29', + 'version.usable_until': '2.0.0p1'} diff --git a/check_mk-clever-pdu/cmk1.6/clever_pdu_1-6-1.1.mkp b/check_mk-clever-pdu/cmk1.6/clever_pdu_1-6-1.1.mkp new file mode 100644 index 0000000000000000000000000000000000000000..7cc86c2faf8b0d889cd7ec7de2993c784a0289fc GIT binary patch literal 3508 zcmZ{kX*kpk+lMJjWMoP9eQgqwowAg&>y~XWC1Y%n&`rZ=vWFP5gfWP0*>?&~voA}Sxl@EiCNn|O2CM8;>AcuM2KCuWyuA3bGKn5LJtrUyth1P`_G z@$ti-+unDg){bbNO9Da#aDi3cd(;WxloH|CQJxoWJTsa*AbjV!LVoVWI;<6lwB{Nx0SH0i6`p+& z=j&AKcU$$MOK}8J${fG+`RhofIVIeBg!b<*CQVF&;2;5XZXU0ty$t%;%jM?as2SsD zqy3TxQ<(=tqw4lW=FHISeZ`&xS=R;oO{MsVpm*1*kK4TB>x3_eC|5!usShz5_wi{5 zGoauC&m=99NAu-o=R*IE=k6u6ipK)H+NpzIUQP3@6Z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4T;-T{#CqY66W1ig%$mX_@(fm4(GBbEqIoZy&OR}2m*-3h92Ap-(3?+D^p2CH5frtK zyiN5_B;)3sqBen|VPM^2XLq1rx|gVY5kbjS=BiQKw$u5D7^LD4tI_pz&Dn;dhf_{k zfO^tzR2a{peo)DaD6mA>8x-Hwly~yR|Ltz{lGfE9O9xw}U8g_v)nRKmfW(zSos1xmf0V^)gJ7S2(sD*3o>s&!I*>?<@EsU}4d|$8I zsE7WvROpAjS!OhaBQ#r*^RBjw)x>#up8OuVfoVIR#xk*qS*Ky>v34KYr1_FHQDPQZvRT40{X={{vI(7DNC5 literal 0 HcmV?d00001 diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu new file mode 100644 index 0000000..8a95e02 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu @@ -0,0 +1,13 @@ +title: Clever PDU Units: Power and Voltage +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Power, Voltage and energy on Clever PDU Units. + +item: + ID of the Line. + +discovery: + One service is created for each Line. diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_humidity b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_humidity new file mode 100644 index 0000000..c88d308 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_humidity @@ -0,0 +1,13 @@ +title: Clever PDU Units: Master Humidity +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Master Humidity on Clever PDU Units. + +item: + Master Humidity. + +discovery: + One service is created. diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_temp b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_temp new file mode 100644 index 0000000..2edbd91 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checkman/clever_pdu_temp @@ -0,0 +1,13 @@ +title: Clever PDU Units: Master Temperature +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Master Temperature on Clever PDU Units. + +item: + Master Temperature. + +discovery: + One service is created. diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_120 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_120 new file mode 100644 index 0000000..2389040 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_120 @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_default_levels"] ={ + "voltage": (240, 250), + "current": (32, 33), + "energy": (35000, 36000), + } + +lines = {"Line 1", "Line 2", "Line 3"} +_UNIT_MAP = { + "voltage": "V" , + "current": "A" , + "energy": "W", +} + +def parse_clever_pdu_120(info): + data=info[0] + parsed = {} + parsed = { + "Line 1" : { + "voltage": float(data[0]), + "current": float(data[3])/10, + "energy": float(data[6]), + }, + "Line 2" : { + "voltage": float(data[1]), + "current": float(data[4])/10, + "energy": float(data[7]), + }, + "Line 3" : { + "voltage": float(data[2]), + "current": float(data[5])/10, + "energy": float(data[8]), + }, + "Total Energy" : { + "energy" : float((float(data[0])*float(data[3])/10)) + float((float(data[1])*float(data[4])/10)) + float((float(data[2])*float(data[5])/10)), + }, + + } + return parsed + +def inventory_clever_pdu_120(parsed): + for line in parsed: + yield line, {} + + +def check_clever_pdu_120(item, params, parsed): + if "Total" not in item: + for param in params: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + + yield check_levels( + parsed.get(item).get(param), + param, + (warn, crit), + unit = _UNIT_MAP.get(param), + infoname = param + ) + else: + for param in params: + if "energy" in param: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + yield check_levels( + parsed.get(item).get(param), + param, + (warn, crit), + unit = _UNIT_MAP.get(param), + infoname = param + ) + + + +check_info['clever_pdu_120'] = { + 'parse_function' : parse_clever_pdu_120, + 'inventory_function' : inventory_clever_pdu_120, + 'check_function' : check_clever_pdu_120, + 'service_description' : '%s', + 'has_perfdata' : True, + 'group' : "clever_pdu", + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2', + [ + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + ], + ), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'default_levels_variable' : 'clever_pdu_default_levels', +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_130 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_130 new file mode 100644 index 0000000..d74c7ae --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_130 @@ -0,0 +1,127 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_default_levels"] ={ + "voltage": (240, 250), + "current": (32, 33), + "energy": (35000, 36000), + } + +lines = {"Line 1", "Line 2", "Line 3"} +_UNIT_MAP = { + "voltage": "V" , + "current": "A" , + "energy": "W", +} + + + +def parse_clever_pdu(info): + data=info[0] + parsed = {} + parsed = { + "Line 1" : { + "voltage": float(data[0]), + "current": float(float(data[3])/10), + "energy" : float((float(data[0])*float(data[3])/10)), + }, + "Line 2" : { + "voltage": float(data[1]), + "current": float(float(data[4])/10), + "energy" : float((float(data[1])*float(data[4])/10)), + }, + "Line 3" : { + "voltage": float(data[2]), + "current": float(float(data[5])/10), + "energy" : float((float(data[2])*float(data[5])/10)), + }, + "Total Energy" : { + "energy" : float((float(data[0])*float(data[3])/10)) + float((float(data[1])*float(data[4])/10)) + float((float(data[2])*float(data[5])/10)), + }, + + } + return parsed + +def inventory_clever_pdu(parsed): + for line in parsed: + yield line, {} + + +def check_clever_pdu(item, params, parsed): + if "Total" not in item: + for param in params: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + + yield check_levels( + parsed.get(item).get(param), + param, + (warn, crit), + unit = _UNIT_MAP.get(param), + infoname = param + ) + else: + for param in params: + if "energy" in param: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + yield check_levels( + parsed.get(item).get(param), + param, + (warn, crit), + unit = _UNIT_MAP.get(param), + infoname = param + ) + + +check_info['clever_pdu'] = { + 'parse_function' : parse_clever_pdu, + 'inventory_function' : inventory_clever_pdu, + 'check_function' : check_clever_pdu, + 'service_description' : '%s', + 'has_perfdata' : True, + 'group' : "clever_pdu", + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2', + [ + '1', + '2', + '3', + '4', + '5', + '6', + ], + ), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and not oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'default_levels_variable' : 'clever_pdu_default_levels', +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_120 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_120 new file mode 100644 index 0000000..4e22de7 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_120 @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_humidity_default_levels"] = { + "levels": (60, 70), +} + +def inventory_clever_pdu_humidity_120(info): + yield "Master humidity", {} + + +def check_clever_pdu_humidity_120(item, params, info): + return check_humidity(float(info[0][0]), params) + + +check_info['clever_pdu_humidity_120'] = { + 'inventory_function' : inventory_clever_pdu_humidity_120, + 'check_function' : check_clever_pdu_humidity_120, + 'service_description' : '%s', + 'has_perfdata' : True, + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2.14', ['0']), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'group' : 'humidity', + 'default_levels_variable' : 'clever_pdu_humidity_default_levels', + 'includes' : ['humidity.include'], +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_130 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_130 new file mode 100644 index 0000000..26fd9c1 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_humidity_130 @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_humidity_default_levels"] = { + "levels": (60, 70), +} + +def inventory_clever_pdu_humidity(info): + yield "Master humidity", {} + + +def check_clever_pdu_humidity(item, params, info): + return check_humidity(float(info[0][0]), params) + + +check_info['clever_pdu_humidity'] = { + 'inventory_function' : inventory_clever_pdu_humidity, + 'check_function' : check_clever_pdu_humidity, + 'service_description' : '%s', + 'has_perfdata' : True, + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2.11', ['0']), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and not oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'group' : 'humidity', + 'default_levels_variable' : 'clever_pdu_humidity_default_levels', + 'includes' : ['humidity.include'], +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_120 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_120 new file mode 100644 index 0000000..25f2bfc --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_120 @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_temp_default_levels"] = { + "levels": (60, 70), +} + +def inventory_clever_pdu_temp_120(info): + yield "Master Temperature", {} + + +def check_clever_pdu_temp_120(item, params, info): + return check_temperature(float(info[0][0]), params, "Master Temperature %s" %item) + + +check_info['clever_pdu_temp_120'] = { + 'inventory_function' : inventory_clever_pdu_temp_120, + 'check_function' : check_clever_pdu_temp_120, + 'service_description' : '%s', + 'has_perfdata' : True, + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2.13', ['0']), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'group' : 'temperature', + 'default_levels_variable' : 'clever_pdu_temp_default_levels', + 'includes' : ['temperature.include'], +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_130 b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_130 new file mode 100644 index 0000000..f56de85 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/checks/clever_pdu_temp_130 @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2016 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +factory_settings["clever_pdu_temp_default_levels"] = { + "levels": (60, 70), +} + +def inventory_clever_pdu_temp(info): + yield "Master Temperature", {} + + +def check_clever_pdu_temp(item, params, info): + return check_temperature(float(info[0][0]), params, "Master Temperature %s" %item) + + +check_info['clever_pdu_temp'] = { + 'inventory_function' : inventory_clever_pdu_temp, + 'check_function' : check_clever_pdu_temp, + 'service_description' : '%s', + 'has_perfdata' : True, + 'snmp_info' : ('.1.3.6.1.4.1.30966.10.3.2.10', ['0']), + 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.30966") and not oid(".1.3.6.1.4.1.30966.10.3.2.70.0"), + 'group' : 'temperature', + 'default_levels_variable' : 'clever_pdu_temp_default_levels', + 'includes' : ['temperature.include'], +} diff --git a/check_mk-clever-pdu/cmk1.6/local/share/check_mk/web/plugins/wato/clever_pdu.py b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/web/plugins/wato/clever_pdu.py new file mode 100755 index 0000000..41a2753 --- /dev/null +++ b/check_mk-clever-pdu/cmk1.6/local/share/check_mk/web/plugins/wato/clever_pdu.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +from cmk.gui.i18n import _ +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersEnvironment, +) +from cmk.gui.valuespec import Dictionary, Integer, TextAscii, Tuple + + +def _parameter_valuespec_clever_pdu(): + return Dictionary( + elements=[ + ( + "voltage", + Tuple( + title=_("Voltage on Line"), + elements=[ + Integer(title=_("warning at"), unit=_("V")), + Integer(title=_("critical at"), unit=_("V")), + ], + ), + ), + ( + "current", + Tuple( + title=_("Current on Power Channel"), + elements=[ + Integer(title=_("warning if below"), unit=_("A")), + Integer(title=_("critical if below"), unit=_("A")), + ], + ), + ), + ( + "energy", + Tuple( + title=_("Active Energy of Line"), + elements=[ + Integer(title=_("warning at"), unit=_("W")), + Integer(title=_("critical at"), unit=_("W")), + ], + ), + ), + ], + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name="clever_pdu", + group=RulespecGroupCheckParametersEnvironment, + item_spec=lambda: TextAscii(title=_("Line"),), + match_type="dict", + parameter_valuespec=_parameter_valuespec_clever_pdu, + title=lambda: _("Levels for Clever AC PDU Devices"), + ) +) + diff --git a/check_mk-clever-pdu/cmk2/checkman/clever_pdu b/check_mk-clever-pdu/cmk2/checkman/clever_pdu new file mode 100644 index 0000000..13bb12f --- /dev/null +++ b/check_mk-clever-pdu/cmk2/checkman/clever_pdu @@ -0,0 +1,13 @@ +title: Clever PDU Units: Power and Voltage +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Power, Voltage and energy on Clever PDU Units. + +item: + ID of the Line. + +discovery: + One service is created for each Line. \ No newline at end of file diff --git a/check_mk-clever-pdu/cmk2/checkman/clever_pdu_humidity b/check_mk-clever-pdu/cmk2/checkman/clever_pdu_humidity new file mode 100644 index 0000000..1880835 --- /dev/null +++ b/check_mk-clever-pdu/cmk2/checkman/clever_pdu_humidity @@ -0,0 +1,13 @@ +title: Clever PDU Units: Master Humidity +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Master Humidity on Clever PDU Units. + +item: + Master Humidity. + +discovery: + One service is created. \ No newline at end of file diff --git a/check_mk-clever-pdu/cmk2/checkman/clever_pdu_temp b/check_mk-clever-pdu/cmk2/checkman/clever_pdu_temp new file mode 100644 index 0000000..9d77c2e --- /dev/null +++ b/check_mk-clever-pdu/cmk2/checkman/clever_pdu_temp @@ -0,0 +1,13 @@ +title: Clever PDU Units: Master Temperature +agents: snmp +catalog: hw/power/clever +license: GPLv2 +distribution: check_mk +description: + Monitors Master Temperature on Clever PDU Units. + +item: + Master Temperature. + +discovery: + One service is created. \ No newline at end of file diff --git a/check_mk-clever-pdu/cmk2/clever_pdu_2-1.0.1.mkp b/check_mk-clever-pdu/cmk2/clever_pdu_2-1.0.1.mkp new file mode 100644 index 0000000000000000000000000000000000000000..380207437801f69e83af99bc558d62adf0f5af28 GIT binary patch literal 3733 zcmZ{l_dnE+1IIY44d>X&E;yT zyx92Uu4MhWYT^sX>|*T2;5#GL)#c>GZ}w;*fEqe_Q=~V1CMu&cV?|X6ql(n}CycdA zcIj`${EMzZIyAz7!uTB6pyv2wANw^aqh9ee(Sq`v{RSQhOttZ`Y4))wCw9I1I#XMA zK8tlLSu%LnU5$k_ERYUE^2swpkS@UYX`wI}k3vp^?VEYelmh{Kuc!Kt{Pa|j0V)LR z7O@H`Gj`Q6<0yIN^#F@Np;#Ve&USjOL4k$u>f-Xn-G%%kJm{Mw=FNiZVSHsqGwF4F zQS%(DiupE{w%xNPc zBGPiadlgyb?W&#kHLu91^v_jd^Xi&VuT71~EZ!CIrmFSk!>bM@jlSD|hlZm1gTDyH zJX?r{x|0w_v_H80D>jz{8!M%q2fYKs>iRg!3yhKR*CI6SIYVY>g^pk*e5s(YS!rP} zWDK`qDM*#@QMGXlYyV^#YQkw&lU7i zZU-!Pm5)4cea-&yOm{A-e1ME&V(j7IQPj$mXb1^thdw=iy8W5ie%mmqr}0Yy?WsOC z!%pbSiUV06v7k@eru!kRWv9Co?GDgTlfNe%05|SVHY$KfwRRY2@S`yd$^9MV6$Q>T z#*KH2&vq&O3$254o^;2Dd~6@yE1^_amTmWC9^fA*&=MEJP@rFizOo)v;dSfyG0E6- zBp2!v1mz@HzHRhyMVP&Uh`~}=W}uf%YH}2nv4crck5;^^!vk^yvg15CBzyz#G8GMO6aOr_8^C zN(ZufDED|*Mjfkv6AjhAxJ(h;#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z>#-f*54HcHPvI+14oB@kckoADS}}n-)n;a^T;=M-^~_+Y<$rE-bPlfu_+oV}`3}D9 z{pH#MZNEHa37Hx%`K(`1TbaNZJ=jn3@?As69KkM=js153W$EUE zBempn3Mgu33p`m}76i6o8g@6VD} zTC8rC6!b!t^=+H8Tobl6Ed!nOUXw#geKq&Ksn1<__L5CQ8#i05Vd#%+6}n831C5zT zJdQp7<6Rz<#vaJ`U}gX^r@UCE)PJ=4*!c~3e!ft;c7 zCp(9F6l&K`66MxGi^4YoAj;LX2VCiFp$Lal z>*xx`H4snYG&Mi`pT(MCGlM;MYXX^ES^(I_vF;2|$9hX_MqLx~fH^v%Umymc)wC@i zqgHK!d|z7qeeysHbTqUUu;Xt%K=CU95QXXSbD-rPMfHDmpo(MT;$k?o_7WPbzy#sY zjgGy8=;$!8p+xb|)#efyv6A`+BjP{*lqT}3-^eQy!iSJTl^eye98G&=vr@a*(U+8& z;kc)Z**cl`M?(1bE;re!wvk6)dJ!Nqh`|m7=VrpOMOonaMgw;>oruW`*1T2q|5q z`H@i)y4}bylK+%*)N*ftYc1w_w|Qgw;4=|7S~XUp`TD`LnQ>NQ9PDlA(Xb<-eUY&$ zCK2pwg+q!XiIy?^?hES6Y9qx8R(2lijVBpu^}zm#noC=N-sv0sZD?*9e_|9f`2Ps> TUsl;NoFE9kQkaaj literal 0 HcmV?d00001 diff --git a/check_mk-clever-pdu/cmk2/info b/check_mk-clever-pdu/cmk2/info new file mode 100644 index 0000000..92d221d --- /dev/null +++ b/check_mk-clever-pdu/cmk2/info @@ -0,0 +1,20 @@ +{'author': 'George Pochiscan', + 'description': 'Ported Clever AC PDU from 2.1.0 checkmk version to 2.0.0 ' + 'checkmk version.\n', + 'download_url': '', + 'files': {'agent_based': ['utils/humidity.py', + 'clever_pdu_120.py', + 'clever_pdu_130.py', + 'clever_pdu_humidity_120.py', + 'clever_pdu_humidity_130.py', + 'clever_pdu_temp_120.py', + 'clever_pdu_temp_130.py'], + 'checkman': ['clever_pdu', 'clever_pdu_humidity', 'clever_pdu_temp'], + 'web': ['plugins/wato/clever_pdu.py']}, + 'name': 'clever_pdu_2', + 'num_files': 11, + 'title': 'Clever PDU checks for 2.0 checkmk version', + 'version': '1.0.1', + 'version.min_required': '2.0.0p20', + 'version.packaged': '2.0.0p29', + 'version.usable_until': '2.1.0p20'} \ No newline at end of file diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_120.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_120.py new file mode 100644 index 0000000..496f1a3 --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_120.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from dataclasses import dataclass +from typing import Iterable, Mapping, Tuple, NamedTuple +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, all_of, exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable + + +def parse_clever_pdu_120(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Line 1" : { + "voltage": float(data[0]), + "current": float(data[3])/10, + "energy": float(data[6]), + }, + "Line 2" : { + "voltage": float(data[1]), + "current": float(data[4])/10, + "energy": float(data[7]), + }, + "Line 3" : { + "voltage": float(data[2]), + "current": float(data[5])/10, + "energy": float(data[8]), + }, + "Total Energy" : { + "energy" : float((float(data[0])*float(data[3])/10)) + float((float(data[1])*float(data[4])/10)) + float((float(data[2])*float(data[5])/10)), + }, + } + return parsed + + +_UNIT_MAP = { + "voltage": "V" , + "current": "A" , + "energy": "W", +} + + +register.snmp_section( + name="clever_pdu_120", + parsed_section_name="clever_pdu_120", + parse_function=parse_clever_pdu_120, + detect = all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "1", # mVoltageA + "2", # mVoltageB + "3", # mVoltageC + "4", # mCurrentA + "5", # mCurrentB + "6", # mCurrentC + "7", # mEnergyA + "8", # mEnergyB + "9", # mEnergyC + ], + ), +) + + +def discover_clever_pdu_120(section) -> DiscoveryResult: + yield from (Service(item=line_num) for line_num in section) + + +def check_clever_pdu_120(item, params, section) -> CheckResult: + if "Total" not in item: + for param in params: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + + yield from check_levels( + section.get(item)[param], + levels_upper = levels_upper, + levels_lower = levels_lower, + metric_name = param, + render_func=lambda v: f"{v:.2f} {_UNIT_MAP[param]}", + label = param, + ) + else: + for param in params: + if "energy" in param: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + yield from check_levels( + section.get(item)[param], + levels_upper = levels_upper, + levels_lower = levels_lower, + metric_name = param, + render_func=lambda v: f"{v:.2f} {_UNIT_MAP[param]}", + label = param, + ) + + + +register.check_plugin( + name="clever_pdu_120", + service_name="%s", + discovery_function=discover_clever_pdu_120, + check_function=check_clever_pdu_120, + check_ruleset_name="clever_pdu", + check_default_parameters={ + "voltage": (220, 210), + "current": (32, 33), + "energy": (35000, 36000), + }, +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_130.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_130.py new file mode 100644 index 0000000..fe00201 --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_130.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from dataclasses import dataclass +from typing import Iterable, Mapping, Tuple, NamedTuple +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, all_of, not_exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable + + +def parse_clever_pdu_130(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Line 1" : { + "voltage": float(data[0]), + "current": float(data[3])/10, + "energy" : float((float(data[0])*float(data[3])/10)), + }, + "Line 2" : { + "voltage": float(data[1]), + "current": float(data[4])/10, + "energy" : float((float(data[1])*float(data[4])/10)), + }, + "Line 3" : { + "voltage": float(data[2]), + "current": float(data[5])/10, + "energy" : float((float(data[2])*float(data[5])/10)), + }, + "Total Energy" : { + "energy" : float((float(data[0])*float(data[3])/10)) + float((float(data[1])*float(data[4])/10)) + float((float(data[2])*float(data[5])/10)), + }, + } + return parsed + +lines = {"Line 1", "Line 2", "Line 3"} + + +_UNIT_MAP = { + "voltage": "V" , + "current": "A" , + "energy": "W", +} + + +register.snmp_section( + name="clever_pdu_130", + parsed_section_name="clever_pdu_130", + parse_function=parse_clever_pdu_130, + detect = all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + not_exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "1", # mVoltageA + "2", # mVoltageB + "3", # mVoltageC + "4", # mCurrentA + "5", # mCurrentB + "6", # mCurrentC + ], + ), +) + + +def discover_clever_pdu_130(section) -> DiscoveryResult: + yield from (Service(item=line_num) for line_num in section) + + +def check_clever_pdu_130(item, params, section) -> CheckResult: + if "Total" not in item: + for param in params: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + + yield from check_levels( + section.get(item)[param], + levels_upper = levels_upper, + levels_lower = levels_lower, + metric_name = param, + render_func=lambda v: f"{v:.2f} {_UNIT_MAP[param]}", + label = param, + ) + else: + for param in params: + if "energy" in param: + levels_lower = levels_upper = None + warn, crit = params.get(param) + if warn > crit: + levels_lower = warn, crit + else: + levels_upper = warn, crit + yield from check_levels( + section.get(item)[param], + levels_upper = levels_upper, + levels_lower = levels_lower, + metric_name = param, + render_func=lambda v: f"{v:.2f} {_UNIT_MAP[param]}", + label = param, + ) + + + +register.check_plugin( + name="clever_pdu_130", + service_name="%s", + discovery_function=discover_clever_pdu_130, + check_function=check_clever_pdu_130, + check_ruleset_name="clever_pdu", + check_default_parameters={ + "voltage": (220, 210), + "current": (32, 33), + "energy": (35000, 36000), + }, +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_120.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_120.py new file mode 100644 index 0000000..2ebcf24 --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_120.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from typing import Mapping, Any +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, get_value_store, all_of, exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable +from .utils.humidity import check_humidity + +CheckParams = Mapping[str, Any] + +def parse_clever_pdu_humidity_120(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Master Humidity" : int(data[0]), + } + return parsed + + + +register.snmp_section( + name="clever_pdu_humidity_120", + parsed_section_name="clever_pdu_humidity_120", + parse_function=parse_clever_pdu_humidity_120, + detect=all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "14", # mHumidity + ], + ), +) + + +def discover_clever_pdu_humidity_120(section) -> DiscoveryResult: + if section.get("Master Humidity") == 0: + return + else: + yield from (Service(item=item) for item in section) + + +def check_clever_pdu_humidity_120(item, params: CheckParams, section) -> CheckResult: + yield from check_humidity( + section.get("Master Humidity"), + params, + ) + +register.check_plugin( + name="clever_pdu_humidity_120", + service_name="%s", + discovery_function=discover_clever_pdu_humidity_120, + check_function=check_clever_pdu_humidity_120, + check_ruleset_name="humidity", + check_default_parameters={}, + +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_130.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_130.py new file mode 100644 index 0000000..03ca5b0 --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_humidity_130.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from typing import Mapping, Any +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, get_value_store, all_of, not_exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable +from .utils.humidity import check_humidity + +CheckParams = Mapping[str, Any] + +def parse_clever_pdu_humidity(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Master Humidity" : int(data[0]), + } + return parsed + + + +register.snmp_section( + name="clever_pdu_humidity", + parsed_section_name="clever_pdu_humidity", + parse_function=parse_clever_pdu_humidity, + detect=all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + not_exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "11", # mHumidity + ], + ), +) + + +def discover_clever_pdu_humidity(section) -> DiscoveryResult: + if section.get("Master Humidity") == 0: + return + else: + yield from (Service(item=item) for item in section) + + +def check_clever_pdu_humidity(item, params: CheckParams, section) -> CheckResult: + yield from check_humidity( + section.get("Master Humidity"), + params, + ) + +register.check_plugin( + name="clever_pdu_humidity", + service_name="%s", + discovery_function=discover_clever_pdu_humidity, + check_function=check_clever_pdu_humidity, + check_ruleset_name="humidity", + check_default_parameters={}, + +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_120.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_120.py new file mode 100644 index 0000000..9745d1a --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_120.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from dataclasses import dataclass +from typing import Iterable, Mapping, Tuple, NamedTuple +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, get_value_store, all_of, exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable +from .utils.temperature import check_temperature, TempParamDict + +def parse_clever_pdu_temp_120(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Master Temperature" : int(data[0]), + } + return parsed + + + +register.snmp_section( + name="clever_pdu_temp_120", + parsed_section_name="clever_pdu_temp_120", + parse_function=parse_clever_pdu_temp_120, + detect = all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "13", # mTemperature + ], + ), +) + + +def discover_clever_pdu_temp_120(section) -> DiscoveryResult: + if section.get("Master Temperature") == 0: + return + else: + yield from (Service(item=item) for item in section) + + +def check_clever_pdu_temp_120(item, params: TempParamDict, section) -> CheckResult: + if (temperature := section.get(item)) is None: + return + yield from check_temperature( + reading=temperature, + params=params, + unique_name=item, + value_store=get_value_store(), + ) + + + +register.check_plugin( + name="clever_pdu_temp_120", + service_name="%s", + discovery_function=discover_clever_pdu_temp_120, + check_function=check_clever_pdu_temp_120, + check_ruleset_name="temperature", + check_default_parameters={}, + +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_130.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_130.py new file mode 100644 index 0000000..e9ec14e --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/clever_pdu_temp_130.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. +from dataclasses import dataclass +from typing import Iterable, Mapping, Tuple, NamedTuple +from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, get_value_store, all_of, not_exists +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable +from .utils.temperature import check_temperature, TempParamDict + +def parse_clever_pdu_temp(string_table: StringTable): + data=string_table[0] + parsed = {} + parsed = { + "Master Temperature" : int(data[0]), + } + return parsed + + + +register.snmp_section( + name="clever_pdu_temp", + parsed_section_name="clever_pdu_temp", + parse_function=parse_clever_pdu_temp, + detect = all_of( + equals( + ".1.3.6.1.2.1.1.2.0", + ".1.3.6.1.4.1.30966", + ), + not_exists(".1.3.6.1.4.1.30966.10.3.2.70.0"), + ), + fetch=SNMPTree( + ".1.3.6.1.4.1.30966.10.3.2", + [ + "10", # mTemperature + ], + ), +) + + +def discover_clever_pdu_temp(section) -> DiscoveryResult: + if section.get("Master Temperature") == 0: + return + else: + yield from (Service(item=item) for item in section) + + +def check_clever_pdu_temp(item, params: TempParamDict, section) -> CheckResult: + if (temperature := section.get(item)) is None: + return + yield from check_temperature( + reading=temperature, + params=params, + unique_name=item, + value_store=get_value_store(), + ) + + + +register.check_plugin( + name="clever_pdu_temp", + service_name="%s", + discovery_function=discover_clever_pdu_temp, + check_function=check_clever_pdu_temp, + check_ruleset_name="temperature", + check_default_parameters={}, + +) diff --git a/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/utils/humidity.py b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/utils/humidity.py new file mode 100644 index 0000000..33bbcfe --- /dev/null +++ b/check_mk-clever-pdu/cmk2/local/lib/python3/cmk/base/plugins/agent_based/utils/humidity.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. + +from typing import Any, List, Mapping, Optional, Tuple, Union + +from ..agent_based_api.v1 import check_levels, render, type_defs + +CheckParams = Union[ + None, Mapping[str, Any], Optional[List[float]], Tuple[float, float, float, float] +] + + +def check_humidity(humidity: float, params: CheckParams) -> type_defs.CheckResult: + levels_upper, levels_lower = None, None + if isinstance(params, dict): + levels_upper = params.get("levels") or None + levels_lower = params.get("levels_lower") or None + elif isinstance(params, (list, tuple)): + # old params = (crit_low , warn_low, warn, crit) + levels_upper = params[2], params[3] + levels_lower = params[1], params[0] + + yield from check_levels( + humidity, + levels_upper=levels_upper, + levels_lower=levels_lower, + metric_name="humidity", + render_func=render.percent, + boundaries=(0, 100), + ) diff --git a/check_mk-clever-pdu/cmk2/plugins/wato/clever_pdu.py b/check_mk-clever-pdu/cmk2/plugins/wato/clever_pdu.py new file mode 100644 index 0000000..fc43b6f --- /dev/null +++ b/check_mk-clever-pdu/cmk2/plugins/wato/clever_pdu.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. + +from cmk.gui.i18n import _ +from cmk.gui.plugins.wato.utils import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersEnvironment, +) +from cmk.gui.valuespec import Dictionary, Integer, TextInput, Tuple + + +def _parameter_valuespec_clever_pdu(): + return Dictionary( + elements=[ + ( + "voltage", + Tuple( + title=_("Voltage on Line"), + elements=[ + Integer(title=_("warning at"), unit=_("V")), + Integer(title=_("critical at"), unit=_("V")), + ], + ), + ), + ( + "current", + Tuple( + title=_("Current on Power Channel"), + elements=[ + Integer(title=_("warning if below"), unit=_("A")), + Integer(title=_("critical if below"), unit=_("A")), + ], + ), + ), + ( + "energy", + Tuple( + title=_("Active Energy of Line"), + elements=[ + Integer(title=_("warning at"), unit=_("W")), + Integer(title=_("critical at"), unit=_("W")), + ], + ), + ), + ], + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name="clever_pdu", + group=RulespecGroupCheckParametersEnvironment, + item_spec=lambda: TextInput( + title=_("Line"), help=_("The Line Number. Example: 'Line 1'.") + ), + match_type="dict", + parameter_valuespec=_parameter_valuespec_clever_pdu, + title=lambda: _("Levels for Clever AC PDU Devices"), + ) +) +