Module: check_mk
Branch: master
Commit: 69e1053f44ea3c415ea243340fd6a00dde3e8c74
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=69e1053f44ea3c…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Wed Jul 31 17:56:57 2013 +0200
emcvnx_hwstatus: inventory now works
---
checks/emcvnx_hwstatus | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/checks/emcvnx_hwstatus b/checks/emcvnx_hwstatus
index e262bc8..6f1197d 100644
--- a/checks/emcvnx_hwstatus
+++ b/checks/emcvnx_hwstatus
@@ -59,29 +59,33 @@
# ]
# }
+ok_states = ("Present", "Valid")
+
def parse_emcvnx_hwstatus(info):
parsed = {}
for line in info:
if len(line) > 3 and line[1] == "Bus" and line[3] ==
"Enclosure":
# print "found1: %s" % line
encid = line[2] + "/" + line[4]
- enc = []
+ enc = {}
parsed[encid] = enc
elif len(line) > 6 and line[6] == "State:":
# print "found2: %s" % line
device = line[4] + " " + line[5]
state = line[-1]
- parsed[encid].append({device: state})
+ #parsed[encid]{device} = state
+ #parsed[encid].append((device, state))
+ enc[device] = state
elif len(line) > 7 and (line[5] == "Module" or line[6] ==
"Cabling") and line[7] == "State:":
# print "found3: %s" % line
device = line[4] + " " + line[5] + " " + line[6]
state = line[-1]
- parsed[encid].append((device, state))
+ enc[device] = state
elif len(line) > 9 and line[7] == "Module" and line[9] ==
"State:":
# print "found4: %s" % line
device = line[4] + " " + line[5] + " " + line[6] + "
" + line[7] + " " + line[8]
state = line[-1]
- parsed[encid].append((device, state))
+ enc[device] = state
else:
# print "ignore: %s" % line
pass
@@ -92,15 +96,15 @@ def parse_emcvnx_hwstatus(info):
def inventory_emcvnx_hwstatus(info):
parsed = parse_emcvnx_hwstatus(info)
inventory = []
- import pprint ; pprint.pprint(parsed)
+ #import pprint ; pprint.pprint(parsed)
for enclosure in parsed:
- print enclosure
- print parsed [enclosure]
- #for sensor in parsed[line]
- # print sensor
- # print parsed[line][0]
- # inventory.append( (line + " " + parsed[line][0], "", None) )
+ #print enclosure
+ #print parsed[enclosure]
+ for sensor in parsed[enclosure].iterkeys():
+ #print "sensor %s vaule %s" % (sensor, parsed[enclosure][sensor])
+ if parsed[enclosure][sensor] in ok_states:
+ inventory.append( (enclosure + " " + sensor, "", None) )
return inventory
def check_emcvnx_hwstatus(item, _no_params, info):