Module: check_mk
Branch: master
Commit: 537d490e6a6d6d02d0d0059b41a56c68b0834e6e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=537d490e6a6d6d…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Tue Aug 14 19:18:21 2012 +0200
cbl_airlaser: add new parser function for hardware checks. inventory/checks disabled
---
checks/cbl_airlaser | 142 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 137 insertions(+), 5 deletions(-)
diff --git a/checks/cbl_airlaser b/checks/cbl_airlaser
index d38fdfd..3916f21 100644
--- a/checks/cbl_airlaser
+++ b/checks/cbl_airlaser
@@ -32,13 +32,131 @@
# .1.3.6.1.4.1.2800.2.1.3 < AirLaser Status
+def parse_cbl_airlaser(info):
+
+ airlaser_status_names = { 0: 'undefined', 1: 'active', 2:
'standby',
+ 3 : 'warning', 4: 'failure', 5:
'not_installed' }
+
+
+# I have my own little MIB right here, their MIB is
+# just a long list, not structured.
+ airlaser_sensors = {
+ "chassis" : {
+ # Name of OID, Value, specific OID (not used), Position in SNMP data
+ "chassisFrontScreenTempStatus" : ( None, "2.1.1.0", 0
),
+ "chassisFrontScreenTempValue" : ( None, "2.1.2.0", 1
),
+ "chassisHeatingStatus" : ( None, "2.1.7.0", 6
),
+ "chassisTempStatus" : ( None, "2.1.8.0", 7
),
+ "chassisTempValue" : ( None, "2.1.9.0", 8
),
+ "chassisFan1Status" : ( None, "2.1.10.0", 9
),
+ "chassisFan2Status" : ( None, "2.1.12.0", 11),
+ },
+ "power" : {
+ "psStatus48V" : ( None, "2.2.2.0", 1),
+ "psStatus230V" : ( None, "2.2.3.0", 2),
+ "psStatus5V" : ( None, "2.2.4.0", 3),
+ "psStatus3V3" : ( None, "2.2.8.0", 7),
+ "psStatus2V5" : ( None, "2.2.12.0",
11),
+ },
+
+ "module" : {
+ "apmodTempStatus" : (None, "2.3.6.0", 5),
+ "apmodTempValue" : (None, "2.3.7.0", 6),
+ },
+
+ "opttx" : {
+ "opttxTempValue" : (None, "2.4.3.0", 2),
+ "opttxStatusTemp" : (None, "2.4.4.0", 3),
+ },
+
+ "optrx" : {
+ "optrxStatusTemp" : (None, "2.5.3.0", 2),
+ # this is mislabeled "optrxValueTemp"
+ "optrxTempValue" : (None, "2.5.4.0", 3),
+ },
+ }
+
+
+ # load the info into a dict separated by the different MIB regions
+ # Selfest (info[0] is not handled here.
+ data = {
+ "chassis" : info[1],
+ "power" : info[2],
+ "module" : info[3],
+ "opttx" : info[4],
+ "optrx" : info[5],
+ }
+
+
+ # update values from one dict into the other by picking the "offsetted"
values
+ # (optimize at will, if we can make it one-dict-for-all then we 100% sanitized their
MIB)
+ for section in airlaser_sensors.keys():
+ for sensor in airlaser_sensors[section].keys():
+ # we could remove the offset hack by parsing our OID
+ sub_oid = airlaser_sensors[section][sensor][1]
+ offset = airlaser_sensors[section][sensor][2]
+
+
+ if "Status" in sensor:
+ value = airlaser_status_names[int(data[section][offset][0])]
+ else:
+ value = saveint(data[section][offset][0])
+ airlaser_sensors[section][sensor] = ( value, sub_oid, offset)
+
+ return airlaser_sensors
+
+
+
+
+def check_cbl_airlaser_hw(item, _no_params, info):
+
+ #import pprint
+ #pprint.pprint(parse_cbl_airlaser(info))
+ state = 0
+ msgtxt = ""
+
+
+ return (3, "UNKNOWN")
+
+ for sensor in airlaser_info.keys():
+ #print sensor
+ #print "1"
+ if sensor.lower().endswith("value"):
+ #print "1a"
+ # das geht noch nicht.
+ #perfdata += [ sensor, saveint(airlaser_info[sensor]),
+ #print saveint(airlaser_info[sensor])
+ continue
+
+ #print "2"
+ #print airlaser_info[sensor]
+ if airlaser_info[sensor] == "failure":
+ #print "2a"
+ state = 2
+ elif airlaser_info[sensor] == "warning":
+ #print "2b"
+ state = max(state, 1)
+ # go here if no explicit error occured,
+ # no handling undefined and not_installed
+ else:
+ print "2c"
+ continue
+ msgtxt = msgtxt + "%s is %s" + state * "!" + " "
+
+ if state == 0:
+ msgtxt = "All sensors OK"
+
+ return (state, nagios_state_names[state] + " - " + msgtxt)
+
def inventory_cbl_airlaser(info):
- # Inventorize if the scan function fired
return [ (None, None) ]
+
def check_cbl_airlaser_status(item, _no_params, info):
- status = info[0][0]
+ selftest, chassis, power, module, optrx, opttx = info
+ status = selftest[0][0]
+
if status == "1":
return (0, "OK - Airlaser: normal operation")
@@ -59,7 +177,21 @@ check_info["cbl_airlaser.status"] = {
"has_perfdata" : False,
"snmp_scan_function" : lambda oid: "airlaser" in
oid(".1.3.6.1.2.1.1.1.0").lower() \
and oid(".1.3.6.1.4.1.2800.2.1.1.0"),
- "snmp_info" : (".1.3.6.1.4.1.2800.2.1", [
- "3", # AirLaser Status
- ]),
+ "snmp_info" : [ (".1.3.6.1.4.1.2800.2", [
"1.3" ]),
+ (".1.3.6.1.4.1.2800.2.2", [ "1" ]),
+ (".1.3.6.1.4.1.2800.2.2", [ "2" ]),
+ (".1.3.6.1.4.1.2800.2.2", [ "3" ]),
+ (".1.3.6.1.4.1.2800.2.2", [ "4" ]),
+ (".1.3.6.1.4.1.2800.2.2", [ "5" ]),
],
+
+}
+
+def inventory_cbl_airlaser_off():
+ return []
+
+check_info["cbl_airlaser.hardware"] = {
+ "check_function" : check_cbl_airlaser_hw,
+ "inventory_function" : inventory_cbl_airlaser_off,
+ "service_description" : "CBL Airlaser Hardware",
+ "has_perfdata" : True,
}