Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / cisco_fantray
blob1f7a59ef61d29cd694ee0860346dc8a9217b40ca
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.
27 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.534 2
28 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.535 2
29 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.536 2
30 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.537 2
31 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.538 2
32 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.539 2
33 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.540 2
34 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.541 2
35 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.113000534 2
36 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.113000535 2
37 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.113000536 2
38 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.116000534 2
39 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.116000535 2
40 # .1.3.6.1.4.1.9.9.117.1.4.1.1.1.116000536 2
42 # .1.3.6.1.2.1.47.1.1.1.1.7.10 Fabric [VPC domain:12]
43 # .1.3.6.1.2.1.47.1.1.1.1.7.22 Nexus 56128P Supervisor in Fixed Module-1
44 # .1.3.6.1.2.1.47.1.1.1.1.7.23 24 ports 10GE SFP+ and 2xQSFP ports Ethernet Module
45 # .1.3.6.1.2.1.47.1.1.1.1.7.149 Nexus 56128P Chassis
46 # .1.3.6.1.2.1.47.1.1.1.1.7.214 Fixed Slot-1
47 # .1.3.6.1.2.1.47.1.1.1.1.7.215 Module Slot-2
48 # .1.3.6.1.2.1.47.1.1.1.1.7.216 Module Slot-3
49 # .1.3.6.1.2.1.47.1.1.1.1.7.278 PowerSupplyBay-1
50 # .1.3.6.1.2.1.47.1.1.1.1.7.279 PowerSupplyBay-2
51 # .1.3.6.1.2.1.47.1.1.1.1.7.280 PowerSupplyBay-3
52 # .1.3.6.1.2.1.47.1.1.1.1.7.281 PowerSupplyBay-4
53 # .1.3.6.1.2.1.47.1.1.1.1.7.342 FanBay-1
54 # .1.3.6.1.2.1.47.1.1.1.1.7.343 FanBay-2
55 # .1.3.6.1.2.1.47.1.1.1.1.7.344 FanBay-3
56 # .1.3.6.1.2.1.47.1.1.1.1.7.345 FanBay-4
57 # .1.3.6.1.2.1.47.1.1.1.1.7.470 PowerSupply-1
58 # .1.3.6.1.2.1.47.1.1.1.1.7.471 PowerSupply-2
59 # .1.3.6.1.2.1.47.1.1.1.1.7.472 PowerSupply-3
60 # .1.3.6.1.2.1.47.1.1.1.1.7.473 PowerSupply-4
61 # .1.3.6.1.2.1.47.1.1.1.1.7.534 FanModule-1
62 # .1.3.6.1.2.1.47.1.1.1.1.7.535 FanModule-2
63 # .1.3.6.1.2.1.47.1.1.1.1.7.536 FanModule-3
64 # .1.3.6.1.2.1.47.1.1.1.1.7.537 FanModule-4
65 # .1.3.6.1.2.1.47.1.1.1.1.7.538 PowerSupply-1 Fan-1
66 # .1.3.6.1.2.1.47.1.1.1.1.7.539 PowerSupply-1 Fan-2
67 # .1.3.6.1.2.1.47.1.1.1.1.7.540 PowerSupply-2 Fan-1
68 # .1.3.6.1.2.1.47.1.1.1.1.7.541 PowerSupply-2 Fan-2
69 # ...
72 def parse_cisco_fantray(info):
73 map_states = {
74 '1': (3, "unknown"),
75 '2': (0, "powered on"),
76 '3': (2, "powered down"),
77 '4': (2, "partial failure, needs replacement as soon as possible.")
80 ppre_parsed = {}
81 for end_oid, oper_state in info[0]:
82 ppre_parsed.setdefault(end_oid,
83 map_states.get(oper_state, (3, "unexpected(%s)" % oper_state)))
85 pre_parsed = {}
86 for end_oid, name in info[1]:
87 if end_oid in ppre_parsed:
88 pre_parsed.setdefault(name, [])
89 pre_parsed[name].append(ppre_parsed[end_oid])
91 parsed = {}
92 for name, infos in pre_parsed.items():
93 if len(infos) > 1:
94 for k, state_info in enumerate(infos):
95 parsed["%s-%d" % (name, k + 1)] = state_info
96 else:
97 parsed[name] = infos[0]
99 return parsed
102 def inventory_cisco_fantray(parsed):
103 for item in parsed:
104 yield item, None
107 def check_cisco_fantray(item, _no_params, parsed):
108 if item in parsed:
109 state, state_readable = parsed[item]
110 return state, "Status: %s" % state_readable
113 check_info["cisco_fantray"] = {
114 'parse_function' : parse_cisco_fantray,
115 'inventory_function' : inventory_cisco_fantray,
116 'check_function' : check_cisco_fantray,
117 'service_description' : 'Fan %s',
118 'snmp_info' : [('.1.3.6.1.4.1.9.9.117.1.4.1.1', [
119 OID_END,
120 '1', # CISCO-ENTITY-FRU-CONTROL-MIB::cefcFanTrayOperStatus
122 ('.1.3.6.1.2.1.47.1.1.1.1', [
123 OID_END,
124 CACHED_OID(7), # ENTITY-MIB::entPhysicalName
125 ])],
126 # Exclude cisco_fan check
127 'snmp_scan_function' : lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() \
128 and not oid(".1.3.6.1.4.1.9.9.13.1.4.1.2.*"),