Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / cisco_redundancy
blob74a8f32fe47d8f734020ca75beeda527d3174934
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.4.1.9.9.176.1.1.1.0 0 --> CISCO-RF-MIB::cRFStatusUnitId.0
28 # .1.3.6.1.4.1.9.9.176.1.1.2.0 14 --> CISCO-RF-MIB::cRFStatusUnitState.0
29 # .1.3.6.1.4.1.9.9.176.1.1.3.0 0 --> CISCO-RF-MIB::cRFStatusPeerUnitId.0
30 # .1.3.6.1.4.1.9.9.176.1.1.4.0 2 --> CISCO-RF-MIB::cRFStatusPeerUnitState.0
31 # .1.3.6.1.4.1.9.9.176.1.1.6.0 2 --> CISCO-RF-MIB::cRFStatusDuplexMode.0
32 # .1.3.6.1.4.1.9.9.176.1.1.8.0 1 --> CISCO-RF-MIB::cRFStatusLastSwactReasonCode.0
35 def inventory_cisco_redundancy(info):
36 try:
37 swact_reason = info[0][5]
38 except IndexError:
39 pass
40 else:
41 if swact_reason != "1":
42 return [(None, {"init_states": info[0][:5]})]
43 return []
46 def check_cisco_redundancy(_no_item, params, info):
47 map_states = {
48 "unit_state": {
49 "0": "not found",
50 "1": "not known",
51 "2": "disabled",
52 "3": "initialization",
53 "4": "negotiation",
54 "5": "standby cold",
55 "6": "standby cold config",
56 "7": "standby cold file sys",
57 "8": "standby cold bulk",
58 "9": "standby hot",
59 "10": "active fast",
60 "11": "active drain",
61 "12": "active pre-config",
62 "13": "active post-config",
63 "14": "active",
64 "15": "active extra load",
65 "16": "active handback",
67 "duplex_mode": {
68 "2": "False (SUB-Peer not detected)",
69 "1": "True (SUB-Peer detected)",
71 "swact_reason": {
72 "1": "unsupported",
73 "2": "none",
74 "3": "not known",
75 "4": "user initiated",
76 "5": "user forced",
77 "6": "active unit failed",
78 "7": "active unit removed",
82 infotexts = {}
83 for what, states in [("now", info[0][:5]), ("init", params["init_states"])]:
84 unit_id, unit_state, peer_id, peer_state, duplex_mode = states
85 infotexts[what] = "Unit ID: %s (%s), Peer ID: %s (%s), Duplex mode: %s" % \
86 (unit_id, map_states["unit_state"][unit_state], \
87 peer_id, map_states["unit_state"][peer_state], \
88 map_states["duplex_mode"][duplex_mode])
90 unit_id, unit_state, peer_id, peer_state, duplex_mode, _swact_reason = info[0]
92 if params["init_states"] == info[0][:5]:
93 state = 0
94 infotext = "%s, Last swact reason code: %s" % \
95 (infotexts["now"], map_states["swact_reason"][info[0][5]])
96 else:
97 if unit_state in ["2", "9", "14"] or peer_state in ["2", "9", "14"]:
98 state = 1
99 else:
100 state = 2
102 infotext = "Switchover - Old status: %s, New status: %s" % \
103 (infotexts["init"], infotexts["now"])
105 if peer_state == "1":
106 state = 2
108 return state, infotext
111 check_info['cisco_redundancy'] = {
112 'inventory_function' : inventory_cisco_redundancy,
113 'check_function' : check_cisco_redundancy,
114 'service_description' : 'Redundancy Framework Status',
115 'snmp_info' : ('.1.3.6.1.4.1.9.9.176.1.1', [
116 1, # cRFStatusUnitId
117 2, # cRFStatusUnitState
118 3, # cRFStatusPeerUnitId
119 4, # cRFStatusPeerUnitState
120 6, # cRFStatusDuplexMode
121 8, # cRFStatusLastSwactReasonCode
123 'snmp_scan_function' : lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() \
124 and oid(".1.3.6.1.4.1.9.9.176.1.1.*"),