Cleanup config.nodes_of
[check_mk.git] / checks / brocade_mlx_power
blob0bd7c17faf871b33a38c7c3f6c99ce79f7eed47e
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def parse_brocade_mlx_power(info):
29 parsed = {}
31 if len(info[1]) > 0:
32 # .1.3.6.1.4.1.1991.1.1.1.2.2.1
33 for power_id, power_desc, power_state in info[1]:
34 if power_state != "1":
35 parsed[power_id] = {'desc': power_desc, 'state': power_state}
36 else:
37 # .1.3.6.1.4.1.1991.1.1.1.2.1.1
38 for power_id, power_desc, power_state in info[0]:
39 if power_state != "1":
40 parsed[power_id] = {'desc': power_desc, 'state': power_state}
41 return parsed
44 def inventory_brocade_mlx_power(parsed):
45 inventory = []
47 for powersupply_id in parsed.keys():
48 inventory.append((powersupply_id, None))
49 return inventory
52 def check_brocade_mlx_power(item, _no_params, parsed):
53 if item not in parsed.keys():
54 yield 3, "Power supply not found"
56 for powersupply_id in parsed.keys():
57 if powersupply_id == item:
58 if parsed[powersupply_id]['state'] == "2":
59 yield 0, "Power supply reports state: normal"
60 elif parsed[powersupply_id]['state'] == "3":
61 yield 2, "Power supply reports state: failure"
62 elif parsed[powersupply_id]['state'] == "1":
63 yield 3, "Power supply reports state: other"
64 else:
65 yield 3, "Power supply reports an unhandled state (%s)" % parsed[powersupply_id][
66 'state']
69 check_info["brocade_mlx_power"] = {
70 "parse_function": parse_brocade_mlx_power,
71 "check_function": check_brocade_mlx_power,
72 "inventory_function": inventory_brocade_mlx_power,
73 "service_description": "Power supply %s",
74 "snmp_info": [
76 '.1.3.6.1.4.1.1991.1.1.1.2.1.1',
78 1, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyIndex
79 2, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
80 3, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyOperStatus
81 ]),
83 '.1.3.6.1.4.1.1991.1.1.1.2.2.1',
85 2, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2Index
86 3, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2Description
87 4, # FOUNDRY-SN-AGENT-MIB::snChasPwrSupply2OperStatus
90 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1."),