Cleanup config.nodes_of
[check_mk.git] / checks / cisco_fru_module_status
blob2b9cd8c92d120314bd07f4ba2a9bf6bd229b1768
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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.2.1.47.1.1.1.1.2.1 "CISCO1921/K9 chassis" --> ENTITY-MIB::entPhysicalDescr.1
28 # .1.3.6.1.2.1.47.1.1.1.1.2.2 "C1921 Chassis Slot" --> ENTITY-MIB::entPhysicalDescr.2
29 # .1.3.6.1.2.1.47.1.1.1.1.2.3 "C1921 Mother board 2GE, integrated VPN and 2W" --> ENTITY-MIB::entPhysicalDescr.3
30 # .1.3.6.1.2.1.47.1.1.1.1.2.4 "C1921 DaughterCard Slot" --> ENTITY-MIB::entPhysicalDescr.4
31 # .1.3.6.1.2.1.47.1.1.1.1.2.5 "ADSL/VDSL over POTS supporting ADSL1, ADSL2, ADSL2+ and VDSL2" --> ENTITY-MIB::entPhysicalDescr.5
32 # .1.3.6.1.2.1.47.1.1.1.1.2.6 "MPC ATMSAR" --> ENTITY-MIB::entPhysicalDescr.6
33 # .1.3.6.1.2.1.47.1.1.1.1.2.7 "VDSL_ETHERNET" --> ENTITY-MIB::entPhysicalDescr.7
34 # .1.3.6.1.2.1.47.1.1.1.1.2.8 "C1921 DaughterCard Slot" --> ENTITY-MIB::entPhysicalDescr.8
35 # .1.3.6.1.2.1.47.1.1.1.1.2.9 "C1921 ISM Slot" --> ENTITY-MIB::entPhysicalDescr.9
36 # .1.3.6.1.2.1.47.1.1.1.1.2.10 "Embedded Service Engine" --> ENTITY-MIB::entPhysicalDescr.10
37 # .1.3.6.1.2.1.47.1.1.1.1.2.11 "CN Gigabit Ethernet" --> ENTITY-MIB::entPhysicalDescr.11
38 # .1.3.6.1.2.1.47.1.1.1.1.2.12 "CN Gigabit Ethernet" --> ENTITY-MIB::entPhysicalDescr.12
39 # .1.3.6.1.2.1.47.1.1.1.1.2.13 "Container of powerSupply Containers" --> ENTITY-MIB::entPhysicalDescr.13
40 # .1.3.6.1.2.1.47.1.1.1.1.2.14 "Container of Power Supply" --> ENTITY-MIB::entPhysicalDescr.14
41 # .1.3.6.1.2.1.47.1.1.1.1.2.15 "" --> ENTITY-MIB::entPhysicalDescr.15
42 # .1.3.6.1.2.1.47.1.1.1.1.5.1 3 --> ENTITY-MIB::entPhysicalClass.1
43 # .1.3.6.1.2.1.47.1.1.1.1.5.2 5 --> ENTITY-MIB::entPhysicalClass.2
44 # .1.3.6.1.2.1.47.1.1.1.1.5.3 9 --> ENTITY-MIB::entPhysicalClass.3
45 # .1.3.6.1.2.1.47.1.1.1.1.5.4 5 --> ENTITY-MIB::entPhysicalClass.4
46 # .1.3.6.1.2.1.47.1.1.1.1.5.5 9 --> ENTITY-MIB::entPhysicalClass.5
47 # .1.3.6.1.2.1.47.1.1.1.1.5.6 10 --> ENTITY-MIB::entPhysicalClass.6
48 # .1.3.6.1.2.1.47.1.1.1.1.5.7 10 --> ENTITY-MIB::entPhysicalClass.7
49 # .1.3.6.1.2.1.47.1.1.1.1.5.8 5 --> ENTITY-MIB::entPhysicalClass.8
50 # .1.3.6.1.2.1.47.1.1.1.1.5.9 5 --> ENTITY-MIB::entPhysicalClass.9
51 # .1.3.6.1.2.1.47.1.1.1.1.5.10 10 --> ENTITY-MIB::entPhysicalClass.10
52 # .1.3.6.1.2.1.47.1.1.1.1.5.11 10 --> ENTITY-MIB::entPhysicalClass.11
53 # .1.3.6.1.2.1.47.1.1.1.1.5.12 10 --> ENTITY-MIB::entPhysicalClass.12
54 # .1.3.6.1.2.1.47.1.1.1.1.5.13 5 --> ENTITY-MIB::entPhysicalClass.13
55 # .1.3.6.1.2.1.47.1.1.1.1.5.14 5 --> ENTITY-MIB::entPhysicalClass.14
56 # .1.3.6.1.2.1.47.1.1.1.1.5.15 6 --> ENTITY-MIB::entPhysicalClass.15
57 # .1.3.6.1.2.1.47.1.1.1.1.7.1 "CISCO1921/K9 chassis" --> ENTITY-MIB::entPhysicalName.1
58 # .1.3.6.1.2.1.47.1.1.1.1.7.2 "C1921 Chassis Slot 0" --> ENTITY-MIB::entPhysicalName.2
59 # .1.3.6.1.2.1.47.1.1.1.1.7.3 "C1921 Mother board 2GE, integrated VPN and 2W on Slot 0" --> ENTITY-MIB::entPhysicalName.3
60 # .1.3.6.1.2.1.47.1.1.1.1.7.4 "DaughterCard Slot 0 on Card 0" --> ENTITY-MIB::entPhysicalName.4
61 # .1.3.6.1.2.1.47.1.1.1.1.7.5 "ADSL/VDSL over POTS supporting ADSL1, ADSL2, ADSL2+ and VDSL2 on Slot 0 SubSlot 0" --> ENTITY-MIB::entPhysicalName.5
62 # .1.3.6.1.2.1.47.1.1.1.1.7.6 "ATM0/0/0" --> ENTITY-MIB::entPhysicalName.6
63 # .1.3.6.1.2.1.47.1.1.1.1.7.7 "Ethernet0/0/0" --> ENTITY-MIB::entPhysicalName.7
64 # .1.3.6.1.2.1.47.1.1.1.1.7.8 "DaughterCard Slot 1 on Card 0" --> ENTITY-MIB::entPhysicalName.8
65 # .1.3.6.1.2.1.47.1.1.1.1.7.9 "C1921 ISM Slot 0" --> ENTITY-MIB::entPhysicalName.9
66 # .1.3.6.1.2.1.47.1.1.1.1.7.10 "Embedded-Service-Engine0/0" --> ENTITY-MIB::entPhysicalName.10
67 # .1.3.6.1.2.1.47.1.1.1.1.7.11 "GigabitEthernet0/0" --> ENTITY-MIB::entPhysicalName.11
68 # .1.3.6.1.2.1.47.1.1.1.1.7.12 "GigabitEthernet0/1" --> ENTITY-MIB::entPhysicalName.12
69 # .1.3.6.1.2.1.47.1.1.1.1.7.13 "Container of powerSupply Containers" --> ENTITY-MIB::entPhysicalName.13
70 # .1.3.6.1.2.1.47.1.1.1.1.7.14 "Container of Power Supply" --> ENTITY-MIB::entPhysicalName.14
71 # .1.3.6.1.2.1.47.1.1.1.1.7.15 "" --> ENTITY-MIB::entPhysicalName.15
73 # .1.3.6.1.4.1.9.9.117.1.2.1.1.2.5 2 --> CISCO-ENTITY-FRU-CONTROL-MIB::cefcModuleOperStatus.5
76 def parse_cisco_fru_module_status(info):
77 map_state = {
78 "1": (2, "unknown"),
79 "2": (0, "OK"),
80 "3": (1, "disabled"),
81 "4": (1, "OK but diag failed"),
82 "5": (1, "boot"),
83 "6": (1, "self test"),
84 "7": (2, "failed"),
85 "8": (2, "missing"),
86 "9": (2, "mismatch with parent"),
87 "10": (2, "mismatch config"),
88 "11": (2, "diag failed"),
89 "12": (2, "dormant"),
90 "13": (2, "out of service (admin)"),
91 "14": (2, "out of service (temperature)"),
92 "15": (2, "powered down"),
93 "16": (1, "powered up"),
94 "17": (2, "power denied"),
95 "18": (1, "power cycled"),
96 "19": (1, "OK but power over warning"),
97 "20": (1, "OK but power over critical"),
98 "21": (1, "sync in progress"),
99 "22": (1, "upgrading"),
100 "23": (1, "OK but auth failed"),
101 "24": (1, "minimum disruptive restart upgrade"),
102 "25": (1, "firmware mismatch found"),
103 "26": (1, "firmware download success"),
104 "27": (2, "firmware download failure"),
106 collected_entities = {}
107 for oid, _hardware_descr, hardware_type, hardware_name in info[0]:
108 if hardware_type == "9":
109 collected_entities.setdefault(oid, hardware_name)
111 parsed = {}
112 for oid, module_state in info[1]:
113 if oid in collected_entities:
114 parsed[oid] = {
115 "state": map_state[module_state],
116 "name": collected_entities[oid],
119 return parsed
122 def inventory_cisco_fru_module_status(parsed):
123 for module_index in parsed:
124 yield (module_index, None)
127 def check_cisco_fru_module_status(item, _no_params, parsed):
128 if item in parsed:
129 extra_info = ""
130 if parsed[item]["name"]:
131 extra_info += "[%s] " % parsed[item]["name"]
132 state, state_readable = parsed[item]["state"]
133 return state, "%sOperational status: %s" % \
134 (extra_info, state_readable)
137 check_info['cisco_fru_module_status'] = {
138 'parse_function' : parse_cisco_fru_module_status,
139 'inventory_function' : inventory_cisco_fru_module_status,
140 'check_function' : check_cisco_fru_module_status,
141 'service_description' : 'FRU Module Status %s',
142 'snmp_info' : [(".1.3.6.1.2.1.47.1.1.1.1", [
143 OID_END,
144 "2", # entPhysicalDescription
145 "5", # entPhysicalClass
146 "7", # entPhysicalName
148 (".1.3.6.1.4.1.9.9.117.1.2.1.1", [
149 OID_END,
150 "2", # cefcModuleOperStatus
151 ])],
152 'snmp_scan_function' : lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() \
153 and oid(".1.3.6.1.4.1.9.9.117.1.*"),