Module: check_mk
Branch: master
Commit: 64aa2d0308f5c2954622f56bd768ac608d56fb34
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64aa2d0308f5c2…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Jul 31 15:40:01 2014 +0200
First fix for raritan_pdu_inlet, not finished yet
---
checks/raritan_pdu_inlet | 174 +++++++++++++++++-----------------------------
1 file changed, 62 insertions(+), 112 deletions(-)
diff --git a/checks/raritan_pdu_inlet b/checks/raritan_pdu_inlet
index 2afedd8..266e380 100644
--- a/checks/raritan_pdu_inlet
+++ b/checks/raritan_pdu_inlet
@@ -25,41 +25,42 @@
# Boston, MA 02110-1301 USA.
capabilities = {
- 0: "rmsCurrent",
- 2: "unbalancedCurrent",
- 3: "rmsVoltage",
- 4: "activePower",
- 5: "apparentPower",
- 6: "powerFactor",
- 7: "activeEnergy",
- 8: "apparentEnergy"
+ '1' : "rmsVoltage",
+ '2' : "rmsCurrent",
+ '3' : "activePower",
+ '4' : "apparentPower",
+ '5' : "activeEnergy",
+ '9' : "unbalancedCurrent",
+ '-1' : "powerFactor",
+ #'' : "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",
+ '-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 = {
+
+sensor_states = {
-1 : "unavailable",
0 : "open",
1 : "closed",
@@ -75,92 +76,41 @@ states = {
11: "alarmed",
}
-def get_capability(cap_entry, id):
- id = id - 1
- bit = bin(ord(cap_entry))[2:][id]
- if bit == "1":
- return capabilities[id]
+def inventory_raritan_pdu_inlet_summary(info):
+ for line in info:
+ yield capabilities[line[0]], None
-def inventory_raritan_pdu_inlet(info):
- inventory = []
- i = 0
- for line in info[1]:
- i += 1
- cap = get_capability(info[0][0][2][0],i)
- if line[2] == "1" and cap:
- item = info[0][0][0] + "-" + cap
- inventory.append((item, None))
- item = info[0][0][0] + "-" + cap + "_L1"
- inventory.append((item, None))
- item = info[0][0][0] + "-" + cap + "_L2"
- inventory.append((item, None))
- item = info[0][0][0] + "-" + cap + "_L3"
- inventory.append((item, None))
- return inventory
+def check_raritan_pdu_inlet_summary(item, _no_params, info):
+ for unit, digits, availability, sensor_state, sensor_value in info:
+ if capabilities[unit] == item:
+ if availability != '1':
+ yield 2, "Sensor not available"
+ return
-def check_raritan_pdu_inlet(item, _no_params, info):
- kinds = { "": 4, "_L1": 5, "_L2": 6, "_L3": 7
}
- label = info[0][0][0]
- name = info[0][0][1]
- i = 0
- for line in info[1]:
- i += 1
- cap = get_capability(info[0][0][2][0],i)
- for mark, index in kinds.iteritems():
- if cap and label + "-" + cap + mark == item:
- unit = units[int(line[0])]
- digits = int(line[1])
- avail = line[2]
- status = int(line[3])
- status_txt = states[status]
- value = float(line[index]) / 10.0**digits
- message = "sensor " + name
- message += "status \"%s\", value %.2f %s" %
(status_txt,value,unit)
- perfdata = [ (cap+mark, str(value)+unit) ]
- if avail != "1" or status in ( 2, 6 ):
- state = 2
- elif status == 4:
- state = 0
- else:
- state = 1
- return (state, message, perfdata)
+ digits = int(digits)
+ sensor_value = float(sensor_value) / 10**digits
+ yield 0, "Value: %.2f %s" % ( sensor_value, units[unit] )
- return 3, "no such inlet data"
+ sensor_state = int(sensor_state)
+ sensor_text = "Sensor State: " + sensor_states[sensor_state]
+ if sensor_state in [ 2, 6 ]:
+ yield 2, sensor_text
+ elif sensor_state != 4:
+ yield 1, sensor_text
-check_info['raritan_pdu_inlet'] = {
- "inventory_function" : inventory_raritan_pdu_inlet,
- "check_function" : check_raritan_pdu_inlet,
- "service_description" : "Inlet Sensor %s",
+check_info['raritan_pdu_inlet.summary'] = {
+ "inventory_function" : inventory_raritan_pdu_inlet_summary,
+ "check_function" : check_raritan_pdu_inlet_summary,
+ "service_description" : "Inlets %s",
"has_perfdata" : True,
- "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
- [
- "3.3.4.1.6.1.1", # inletSensorUnits
- "3.3.4.1.7.1.1", # inletDecimalDigits
- "5.2.3.1.2.1.1", # inlet sensor availability
- "5.2.3.1.3.1.1", # inlet sensor state
- "5.2.3.1.4.1.1", # inlet sensor value
- "5.2.4.1.4.1.1.1", # inlet sensor L1 value
- "5.2.4.1.4.1.1.2", # inlet sensor L2 value
- "5.2.4.1.4.1.1.3", # inlet sensor L3 value
- ]
- ),
- #( ".1.3.6.1.4.1.13742.6.5.2.4.1.4.1.1", # Properties of the
sensors
- # [
- # "1", # inlet sensor values
- # "2", # inlet sensor values
- # "3", # inlet sensor values
- # ]
- #),
- ],
- "snmp_scan_function" : lambda oid: \
-
oid(".1.3.6.1.4.1.13742.6.3.2.1.1.3.1").startswith("PX2-2")
+ "snmp_info" : ( ".1.3.6.1.4.1.13742.6", [
+ "3.3.4.1.6.1.1", #
inletSensorUnits
+ "3.3.4.1.7.1.1", #
inletDecimalDigits value
+ "5.2.3.1.2.1.1", # inlet
sensor availability
+ "5.2.3.1.3.1.1", # inlet
sensor state
+ "5.2.3.1.4.1.1", # inlet
sensor value
+ ]),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") ==
".1.3.6.1.4.1.13742.6"
+
}