Module: check_mk
Branch: master
Commit: efdc9e8d651ecabcf9744600fa4c2b7cd68c77a8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=efdc9e8d651eca…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Apr 7 15:22:34 2014 +0200
cmciii.humidity: new check for Rittals CMC III humidity sensors
---
.werks/602 | 8 +++++
ChangeLog | 1 +
checkman/cmciii.humidity | 22 ++++++++++++
checks/cmciii | 89 ++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 113 insertions(+), 7 deletions(-)
diff --git a/.werks/602 b/.werks/602
new file mode 100644
index 0000000..5fa7b4e
--- /dev/null
+++ b/.werks/602
@@ -0,0 +1,8 @@
+Title: cmciii.humidity: new check for Rittals CMC III humidity sensors
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1396876884
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 8f140be..6f647db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
* 0151 enterasys_cpu_util: Changed check to not longer summarize all modules...
NOTE: Please refer to the migration notes!
* 0802 ibm_svc_nodestats.iops, ibm_svc_systemstats.iops: new checks for IO
operations/sec on IBM SVC / V7000 devices
+ * 0602 cmciii.humidity: new check for Rittals CMC III humidity sensors
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
* 0786 FIX: zfsget: fixed compatibility with older Solaris agents...
* 0809 FIX: brocade_fcport: Fixed recently introduced problem with port speed
detection
diff --git a/checkman/cmciii.humidity b/checkman/cmciii.humidity
new file mode 100644
index 0000000..3cde75c
--- /dev/null
+++ b/checkman/cmciii.humidity
@@ -0,0 +1,22 @@
+title: Rittal CMC-III Units: humidity
+agents: snmp
+catalog: hw/environment/rittal
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the humidity measured by various
+ Rittal CMC-III units.
+ No limits are set in the check, since limits are configured in the
+ Rittal device itself. The state given by the Rittal device is
+ taken as the state of the check as follows:
+ If the Rittal device returns {OK}, the check is {OK}. Otherwise
+ the check is {CRIT}.
+
+item:
+ The unit name and the name of the humidity sensor
+
+perfdata:
+ One variable: the humidity
+
+inventory:
+ All humidity sensors on all cmciii units are detected
diff --git a/checks/cmciii b/checks/cmciii
index 91c8ab3..d608b54 100644
--- a/checks/cmciii
+++ b/checks/cmciii
@@ -171,6 +171,9 @@ def parse_units(info):
num = 0
for unit_type, descname, state in info:
num =+ 1
+ # no blanks in names since we use blanks in items
+ # later to split between unit_name and item_name
+ descname = re.sub(" ", "_", descname)
if descname == '':
descname = unit_type+"-"+str(num)
units.append((unit_type, descname, state))
@@ -455,6 +458,13 @@ def inventory_cmciii_temp(info):
inventory.append( ("%s %s" % (unit_name, item_name), None) )
return inventory
+def parse_temp(val):
+ if re.search(" B0 ", val):
+ # is encoded string
+ val = re.sub(" ","", val).decode("hex")
+ val, t_unit = val.split(" ", 1)
+ return val, t_unit
+
def check_cmciii_temp(item, params, info):
unit_name, item_name = item.split(" ", 1)
parsed = parse_cmciii_inputs(info[0])
@@ -465,14 +475,13 @@ def check_cmciii_temp(item, params, info):
descr = entry.get('DescName')
status = entry.get('Status')
-
- value = re.sub(r' ','',entry.get('Value'))
offset = entry.get('Offset')
- highalarm = entry.get('SetPtHighAlarm').split(" ")[0]
- highwarning = entry.get('SetPtHighWarning').split(" ")[0]
- lowalarm = entry.get('SetPtLowAlarm').split(" ")[0]
- lowwarning = entry.get('SetPtLowWarning').split(" ")[0]
+ value, t_unit = parse_temp(entry.get('Value'))
+ highalarm = parse_temp(entry.get('SetPtHighAlarm'))[0]
+ highwarning = parse_temp(entry.get('SetPtHighWarning'))[0]
+ lowalarm = parse_temp(entry.get('SetPtLowAlarm'))[0]
+ lowwarning = parse_temp(entry.get('SetPtLowWarning'))[0]
if status == "OK":
state = 0
@@ -480,7 +489,7 @@ def check_cmciii_temp(item, params, info):
else:
state = 2
- perfdata = [ ("temp", value, 0, 0 ) ]
+ perfdata = [ ("temp", value+t_unit, 0, 0 ) ]
infotext = "%s %s %s - Limits low %s/%s high %s/%s, Offset %s" % \
( descr, value, status, lowalarm, lowwarning, highwarning,
highalarm, offset )
@@ -646,3 +655,69 @@ check_info['cmciii.state'] = {
"snmp_scan_function" : cmciii_scan,
"snmp_info" : cmciii_snmp_info,
}
+
+#.
+# .--humidity------------------------------------------------------------.
+# | _ _ _ _ _ |
+# | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
+# | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
+# | | | | | |_| | | | | | | | (_| | | |_| |_| | |
+# | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
+# | |___/ |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
+
+def inventory_cmciii_humidity(info):
+ inventory = []
+ parsed = parse_cmciii_inputs(info[0])
+ units = parse_units(info[1])
+ for (unit, item_name), entry in parsed.iteritems():
+ unit_type, unit_name = units[int(unit)-1][0:2]
+ if item_name == 'Humidity' and unit_type == 'CMCIII-HUM':
+ inventory.append( ("%s %s" % (unit_name, item_name), None) )
+
+ return inventory
+
+def parse_hum(val):
+ return val.split(" ", 1)
+
+def check_cmciii_humidity(item, params, info):
+ unit_name, item_name = item.split(" ", 1)
+ parsed = parse_cmciii_inputs(info[0])
+ unit = get_unit_number(parse_units(info[1]), unit_name)
+ entry = parsed.get((unit, item_name))
+ if not entry:
+ return 3, "No such temperature data found"
+
+ descr = entry.get('DescName')
+ status = entry.get('Status')
+ offset = entry.get('Offset')
+
+ value = parse_hum(entry.get('Value'))[0]
+ highalarm = parse_hum(entry.get('SetPtHighAlarm'))[0]
+ highwarning = parse_hum(entry.get('SetPtHighWarning'))[0]
+ lowalarm = parse_hum(entry.get('SetPtLowAlarm'))[0]
+ lowwarning = parse_hum(entry.get('SetPtLowWarning'))[0]
+
+ if status == "OK":
+ state = 0
+ status = ""
+ else:
+ state = 2
+
+ perfdata = [ ("hum", value+"%", 0, 0 ) ]
+
+ infotext = "%s %s%% %s - Limits low %s/%s high %s/%s, Offset %s" % \
+ ( descr, value, status, lowalarm, lowwarning, highwarning,
highalarm, offset )
+
+ return (state, infotext, perfdata)
+
+check_info['cmciii.humidity'] = {
+ "check_function" : check_cmciii_humidity,
+ "inventory_function" : inventory_cmciii_humidity,
+ "service_description" : "%s",
+ "snmp_scan_function" : cmciii_scan,
+ "snmp_info" : cmciii_snmp_info,
+}
+#.