Module: check_mk
Branch: master
Commit: 75c6118c33959c96552a0d673e97e5413948c033
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=75c6118c33959c…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Mon Nov 4 10:15:49 2013 +0100
brocade_mlx: code cleanup
---
checks/brocade_mlx | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/checks/brocade_mlx b/checks/brocade_mlx
index e016c79..576c8af 100644
--- a/checks/brocade_mlx
+++ b/checks/brocade_mlx
@@ -31,6 +31,12 @@ brocade_mlx_info = [ ('.1.3.6.1.4.1.1991.1.1.1.2.1.1', [ 1, 2,
3 ]), # power sup
def brocade_mlx_scan(oid):
return
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1.")
+def combine_item(id, descr):
+ if descr == "":
+ return id
+ else:
+ return "%s: %s" % (id, descr)
+
#############################################################################
# Power Supplies
#############################################################################
@@ -38,20 +44,12 @@ def brocade_mlx_scan(oid):
def inventory_brocade_mlx_power(info):
inventory = []
for power_id, power_descr, power_state in info[0]:
- if power_descr == "":
- power_item = power_id
- else:
- power_item = "%s: %s" % (power_id, power_descr)
- inventory.append( (power_item, None) )
+ inventory.append( (combine_item(power_id, power_descr), None) )
return inventory
def check_brocade_mlx_power(item, _no_params, info):
for power_id, power_descr, power_state in info[0]:
- if power_descr == "":
- power_item = power_id
- else:
- power_item = "%s: %s" % (power_id, power_descr)
- if power_item == item:
+ if combine_item(power_id, power_descr) == item:
if power_state == "2":
return 0, "Power supply reports status 2 (normal)"
elif power_state == "3":
@@ -76,20 +74,12 @@ check_info["brocade_mlx.power"] = {
def inventory_brocade_mlx_fan(info):
inventory = []
for fan_id, fan_descr, fan_state in info[1]:
- if fan_descr == "":
- fan_item = fan_id
- else:
- fan_item = "%s: %s" % (fan_id, fan_descr)
- inventory.append( (fan_item, None) )
+ inventory.append( (combine_item(fan_id, fan_descr), None) )
return inventory
def check_brocade_mlx_fan(item, _no_params, info):
for fan_id, fan_descr, fan_state in info[1]:
- if fan_descr == "":
- fan_item = fan_id
- else:
- fan_item = "%s: %s" % (fan_id, fan_descr)
- if fan_item == item:
+ if combine_item(fan_id, fan_descr) == item:
if fan_state == "2":
return 0, "Fan reports status 2 (normal)"
elif fan_state == "3":