Module: check_mk
Branch: master
Commit: 46785bf8654b1500e446b0e47f9a9badb08af56c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=46785bf8654b15…
Author: Sven Rueß <sr(a)mathias-kettner.de>
Date: Mon Apr 24 14:40:45 2017 +0200
8287 brocade_mlx_power: Added new standard OID for snChasPwrSupply2Table to receive all
power supplies in stacked devices
Added new OID for snChasPwrSupply2Table to receive the information about all available
power supplies
and fixed the item name for all power supplies. Now we take only the index as item name.
This makes
rule creation equal to all temperature checks.
To get all power supplies automatically detected and renamed, you have to make a new
service discovery.
With this servicce discovery it can happen that power supplies will be renamed. Now
historic data and
rules exists for this check. So nothing special have to be done.
Change-Id: Ie6bfc213938cac30f6ce9de5ed967b7788abc1e3
---
.werks/8287 | 17 ++++++++++++
checks/brocade_mlx_power | 72 ++++++++++++++++++++++++++++++++----------------
2 files changed, 65 insertions(+), 24 deletions(-)
diff --git a/.werks/8287 b/.werks/8287
new file mode 100644
index 0000000..ab8664d
--- /dev/null
+++ b/.werks/8287
@@ -0,0 +1,17 @@
+Title: brocade_mlx_power: Added new standard OID for snChasPwrSupply2Table to receive all
power supplies in stacked devices
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cee
+Version: 1.5.0i1
+Date: 1493037069
+Class: feature
+
+Added new OID for snChasPwrSupply2Table to receive the information about all available
power supplies
+and fixed the item name for all power supplies. Now we take only the index as item name.
This makes
+rule creation equal to all temperature checks.
+
+To get all power supplies automatically detected and renamed, you have to make a new
service discovery.
+With this servicce discovery it can happen that power supplies will be renamed. Now
historic data and
+rules exists for this check. So nothing special have to be done.
+
diff --git a/checks/brocade_mlx_power b/checks/brocade_mlx_power
index 2ee1825..f9a7d7d 100644
--- a/checks/brocade_mlx_power
+++ b/checks/brocade_mlx_power
@@ -24,40 +24,64 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def brocade_mlx_power_combine_item(id, descr):
- if descr == "" or "AC " in descr:
- return id
+def parse_brocade_mlx_power(info):
+ parsed = {}
+
+ if len(info[1]) > 0:
+ # .1.3.6.1.4.1.1991.1.1.1.2.2.1
+ for power_unit, power_id, power_desc, power_state in info[1]:
+ if power_state != "1":
+ parsed[power_unit] = { 'desc' : power_desc,
+ 'state' : power_state }
else:
- return "%s %s" % (id, descr)
+ # .1.3.6.1.4.1.1991.1.1.1.2.1.1
+ for power_id, power_desc, power_state in info[0]:
+ if power_state != "1":
+ parsed[power_id] = { 'desc' : power_desc,
+ 'state' : power_state }
+ return parsed
+
-def inventory_brocade_mlx_power(info):
+def inventory_brocade_mlx_power(parsed):
inventory = []
- for power_id, power_descr, power_state in info:
- if power_state != "1":
- inventory.append( (brocade_mlx_power_combine_item(power_id, power_descr),
None) )
+
+ for powersupply_id in parsed.keys():
+ inventory.append((powersupply_id, None))
return inventory
-def check_brocade_mlx_power(item, _no_params, info):
- for power_id, power_descr, power_state in info:
- if brocade_mlx_power_combine_item(power_id, power_descr) == item:
- if power_state == "2":
- return 0, "Power supply reports state: normal"
- elif power_state == "3":
- return 2, "Power supply reports state: failure"
- elif power_state == "1":
- return 3, "Power supply reports state: other"
+
+def check_brocade_mlx_power(item, _no_params, parsed):
+ if item not in parsed.keys():
+ yield 3, "Power supply not found"
+
+ for powersupply_id in parsed.keys():
+ if powersupply_id == item:
+ if parsed[powersupply_id]['state'] == "2":
+ yield 0, "Power supply reports state: normal"
+ elif parsed[powersupply_id]['state'] == "3":
+ yield 2, "Power supply reports state: failure"
+ elif parsed[powersupply_id]['state'] == "1":
+ yield 3, "Power supply reports state: other"
else:
- return 3, "Power supply reports an unhandled state (%s)" %
power_state
- return 3, "Power supply not found"
+ yield 3, "Power supply reports an unhandled state (%s)" %
parsed[powersupply_id]['state']
+
check_info["brocade_mlx_power"] = {
+ "parse_function" : parse_brocade_mlx_power,
"check_function" : check_brocade_mlx_power,
"inventory_function" : inventory_brocade_mlx_power,
"service_description" : "Power supply %s",
- "snmp_info" : ('.1.3.6.1.4.1.1991.1.1.1.2.1.1', [
- 1, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyIndex
- 2, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
- 3, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyOperStatus
- ]),
+ "snmp_info" : [ ('.1.3.6.1.4.1.1991.1.1.1.2.1.1', [
+ 1, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyIndex
+ 2, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
+ 3, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyOperStatus
+ ]),
+ ('.1.3.6.1.4.1.1991.1.1.1.2.2.1', [
+ 1, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2Unit
+ 2, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2Index
+ 3, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2Description
+ 4, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2OperStatus
+ ])
+ ],
"snmp_scan_function" : lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1."),
}