Module: check_mk
Branch: master
Commit: e57268dd783fb1c683a703be14b397df0399630e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e57268dd783fb1…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Fri Dec 13 12:42:04 2013 +0100
raritan_pdu_inlet: new check to monitor inlet sensors of the Raritan PX-2000 PDUs
---
.werks/75 | 8 +++
ChangeLog | 1 +
checkman/raritan_pdu_inlet | 22 +++++++
checks/raritan_pdu_inlet | 146 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 177 insertions(+)
diff --git a/.werks/75 b/.werks/75
new file mode 100644
index 0000000..3d9ce67
--- /dev/null
+++ b/.werks/75
@@ -0,0 +1,8 @@
+Title: raritan_pdu_inlet: new check to monitor inlet sensors of the Raritan PX-2000 PDUs
+Level: 1
+Component: checks
+Version: 1.2.3i8
+Date: 1386934866
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 665aad2..ed6da87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
* 0086 timemachine: new check checking the age of latest backup by timemachine on MAC
OS
* 0074 raritan_pdu_plugs: new check for Raritan PX-2000 family PDUs...
* 0107 stulz_alerts, stulz_powerstate, stulz_temp, stulz_humidity: New Checks for
Stulz clima devices
+ * 0075 raritan_pdu_inlet: new check to monitor inlet sensors of the Raritan PX-2000
PDUs
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/raritan_pdu_inlet b/checkman/raritan_pdu_inlet
new file mode 100644
index 0000000..82239ca
--- /dev/null
+++ b/checkman/raritan_pdu_inlet
@@ -0,0 +1,22 @@
+title: Raritan PX-2000 family PDU inlet sensor state
+agents: snmp
+catalog: hw/other
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the state of the inlet sensors of the Raritan PX-2000
+ family of intelligent rack power distribution units (iPDUs).
+ It has been tested with the model PX2-2180CR.
+ The check displays the measured value of the sensor and the state given
+ by the device.
+ Upper and lower warning and critical limits for the values can be configured
+ in the device itself and the device state is determined accordingly.
+ The state of the check reflects the state of the device.
+
+item:
+ The ID Number of the inlet and the sensor type.
+
+inventory:
+ During inventory all available sensors of the inlet and their type are
+ determined. One check per sensor is created.
+
diff --git a/checks/raritan_pdu_inlet b/checks/raritan_pdu_inlet
new file mode 100644
index 0000000..2d7a8d1
--- /dev/null
+++ b/checks/raritan_pdu_inlet
@@ -0,0 +1,146 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)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-
+# ails. 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.
+
+capabilities = {
+ 0: "rmsCurrent",
+ 2: "unbalancedCurrent",
+ 3: "rmsVoltage",
+ 4: "activePower",
+ 5: "apparentPower",
+ 6: "powerFactor",
+ 7: "activeEnergy",
+ 8: "apparentEnergy"
+}
+
+units = {
+ -1: "",
+ 0: "",
+ 1: "V",
+ 2: "A",
+ 3: "W",
+ 4: "VA",
+ 5: "Wh",
+ 6: "VAh",
+ 7: "C",
+ 8: "Hz",
+ 9: "%",
+ 10: "m/s",
+ 11: "Pascal",
+ 12: "psi",
+ 13: "g",
+ 14: "F",
+ 15: "ft",
+ 16: "in",
+ 17: "cm",
+ 18: "m",
+ 19: "rpm",
+ }
+
+states = {
+ -1 : "unavailable",
+ 0 : "open",
+ 1 : "closed",
+ 2 : "belowLowerCritical",
+ 3 : "belowLowerWarning",
+ 4 : "normal",
+ 5 : "aboveUpperWarning",
+ 6 : "aboveUpperCritical",
+ 7 : "on",
+ 8 : "off",
+ 9 : "detected",
+ 10: "notDetected",
+ 11: "alarmed",
+ }
+
+def get_capability(cap_entry, id):
+ bit = bin(ord(cap_entry))[2:][id]
+ if bit == "1":
+ return capabilities[id]
+
+def inventory_raritan_pdu_inlet(info):
+ inventory = []
+ for line in info[1]:
+ i = int(line[0].split(".")[2]) -1
+ cap = get_capability(info[0][0][2][0],i)
+ if line[3] == "1" and cap:
+ item = info[0][0][0] + "-" + cap
+ inventory.append((item, None))
+ return inventory
+
+def check_raritan_pdu_inlet(item, params, info):
+ state = 3
+ message = "Sensor not found"
+
+ label = info[0][0][0]
+ name = info[0][0][1]
+ for line in info[1]:
+ i = int(line[0].split(".")[2]) - 1
+ cap = get_capability(info[0][0][2][0],i)
+ if label + "-" + cap == item:
+ unit = units[int(line[1])]
+ digits = int(line[2])
+ avail = line[3]
+ status = int(line[4])
+ status_txt = states[status]
+ value = float(line[5]) / 10.0**digits
+ message = "sensor " + name
+ message += "status \"%s\", value %.2f%s" %
(status_txt,value,unit)
+ if avail != "1" or status in ( 2, 6 ):
+ state = 2
+ elif status == 4:
+ state = 0
+ else:
+ state = 1
+
+ return (state, message)
+
+check_info['raritan_pdu_inlet'] = {
+ "inventory_function" : inventory_raritan_pdu_inlet,
+ "check_function" : check_raritan_pdu_inlet,
+ "service_description" : "Inlet Sensor %s",
+ "has_perfdata" : False,
+ "snmp_info" : [
+ (".1.3.6.1.4.1.13742.6", # General properties of the inlet
+ [
+ "3.3.3.1.2", # label
+ "3.3.3.1.3", # name
+ "3.3.3.1.10", # capabilites
+ ]
+ ),
+ ( ".1.3.6.1.4.1.13742.6", # Properties of the sensors
+ [
+ OID_END,
+ "3.3.4.1.6", # inletSensorUnits
+ "3.3.4.1.7", # inletDecimalDigits
+ "5.2.3.1.2", # inlet sensor availability
+ "5.2.3.1.3", # inlet sensor state
+ "5.2.3.1.4", # inlet sensor value
+ ]
+ )],
+ "snmp_scan_function" : lambda oid: \
+
oid(".1.3.6.1.4.1.13742.6.3.2.1.1.3.1").startswith("PX2-2")
+
+}