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