2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080094a91.shtml
29 #.1.3.6.1.4.1.9.9.106.1.1.1.0 5
31 ###########################
32 #.1.3.6.1.4.1.9.9.106.1.2.1.1.2.1.192 "HSRP Secret key here"
33 #.1.3.6.1.4.1.9.9.106.1.2.1.1.2.7.193 "HSRP Secret key here"
34 #.1.3.6.1.4.1.9.9.106.1.2.1.1.3.1.192 100
35 #.1.3.6.1.4.1.9.9.106.1.2.1.1.3.7.193 100
36 #.1.3.6.1.4.1.9.9.106.1.2.1.1.4.1.192 1
37 #.1.3.6.1.4.1.9.9.106.1.2.1.1.4.7.193 1
38 #.1.3.6.1.4.1.9.9.106.1.2.1.1.5.1.192 300
39 #.1.3.6.1.4.1.9.9.106.1.2.1.1.5.7.193 300
40 #.1.3.6.1.4.1.9.9.106.1.2.1.1.6.1.192 2
41 #.1.3.6.1.4.1.9.9.106.1.2.1.1.6.7.193 2
42 #.1.3.6.1.4.1.9.9.106.1.2.1.1.7.1.192 0
43 #.1.3.6.1.4.1.9.9.106.1.2.1.1.7.7.193 0
44 #.1.3.6.1.4.1.9.9.106.1.2.1.1.8.1.192 0
45 #.1.3.6.1.4.1.9.9.106.1.2.1.1.8.7.193 0
46 #.1.3.6.1.4.1.9.9.106.1.2.1.1.9.1.192 3000
47 #.1.3.6.1.4.1.9.9.106.1.2.1.1.9.7.193 3000
48 #.1.3.6.1.4.1.9.9.106.1.2.1.1.10.1.192 10000
49 #.1.3.6.1.4.1.9.9.106.1.2.1.1.10.7.193 10000
50 #.1.3.6.1.4.1.9.9.106.1.2.1.1.11.1.192 192.168.10.4
51 #.1.3.6.1.4.1.9.9.106.1.2.1.1.11.7.193 172.20.10.20 <- hsrp ip
52 #.1.3.6.1.4.1.9.9.106.1.2.1.1.12.1.192 1
53 #.1.3.6.1.4.1.9.9.106.1.2.1.1.12.7.193 1
54 # HSRP Monitored IP interfaces. If any of those go down, the priority of
55 # the router will be lowered.
56 #.1.3.6.1.4.1.9.9.106.1.2.1.1.13.1.192 192.168.10.5 <- ip Router 1 int 1
57 #.1.3.6.1.4.1.9.9.106.1.2.1.1.13.7.193 172.20.10.21 <- ip Router 2 int 7
58 #.1.3.6.1.4.1.9.9.106.1.2.1.1.14.1.192 192.168.10.6 <- ip Router 1 int 1
59 #.1.3.6.1.4.1.9.9.106.1.2.1.1.14.7.193 172.20.10.22 <- ip Router 2 int 7
60 #.1.3.6.1.4.1.9.9.106.1.2.1.1.15.1.192 6 <- group #1 "standby" state
61 #.1.3.6.1.4.1.9.9.106.1.2.1.1.15.7.193 6 <- group #2 "standby" state
62 #.1.3.6.1.4.1.9.9.106.1.2.1.1.16.1.192 "00 00 0C 07 AC C0 "
63 #.1.3.6.1.4.1.9.9.106.1.2.1.1.16.7.193 "00 00 0C 07 AC C1 "
64 #.1.3.6.1.4.1.9.9.106.1.2.1.1.17.1.192 1
65 #.1.3.6.1.4.1.9.9.106.1.2.1.1.17.7.193 1
67 # we'll be alerting if the state is not either 5 or 6.
68 # We could also not inventorize if the state isn't 5/6 but
69 # since you have to configure a group, to even show up in the
70 # MIB it's supposedly ok to alert if something isn't right there.
71 # otherwise modify the inventory.
72 hsrp_states
= {1: "initial", 2: "learn", 3: "listen", 4: "speak", 5: "standby", 6: "active"}
75 def inventory_cisco_hsrp(info
):
78 hsrp_grp_entry
, vip
, _actrouter
, _sbrouter
, hsrp_state
, _vmac
= line
79 _interface_index
, hsrp_grp
= hsrp_grp_entry
.split(".")
80 hsrp_state
= int(hsrp_state
)
81 # if the group is in a working state (both routers see and talk to each other),
82 # inventorize HSRP group name+IP and the standby state as seen from "this" box.
83 if hsrp_state
in [5, 6]:
84 vip_grp
= "%s-%s" % (vip
, hsrp_grp
)
85 inventory
.append((vip_grp
, (hsrp_grp
, hsrp_state
)))
90 def check_cisco_hsrp(item
, params
, info
):
92 _hsrp_grp_wanted
, hsrp_state_wanted
= params
95 hsrp_grp_entry
, vip
, _actrouter
, _sbrouter
, hsrp_state
, _vmac
= line
96 _interface_index
, hsrp_grp
= hsrp_grp_entry
.split(".")
97 hsrp_state
= int(hsrp_state
)
100 vip_grp
= "%s-%s" % (vip
, hsrp_grp
)
105 # FIXME: This should be shorter.
106 # Validate that we the inventorized state is a "good one"
107 # if it's also the one we have now, then we're fine.
109 if hsrp_state_wanted
in [3, 5, 6] and hsrp_state
== hsrp_state_wanted
:
111 msgtxt
= "Redundancy Group %s is OK" % vip_grp
112 # otherwise if it's a good one, but flipped, then we are in a failover
113 elif hsrp_state
in [5, 6]:
115 msgtxt
= "Redundancy Group %s has failed over" % hsrp_grp
116 # anything else must be a non-operative state already
119 msgtxt
= "Redundancy Group %s" % hsrp_grp
121 return state
, "%s, Status: %s" % (msgtxt
, hsrp_states
.get(hsrp_state
, "unknown"))
123 return 3, "HSRP Group not found in Agent output"
126 check_info
["cisco_hsrp"] = {
127 "inventory_function": inventory_cisco_hsrp
,
128 "check_function": check_cisco_hsrp
,
129 "service_description": "HSRP Group %s",
131 ".1.3.6.1.4.1.9.9.106.1.2.1.1",
134 "11", # cHsrpGrpVirtualIpAddr
135 "13", # cHsrpGrpActiveRouter
136 "14", # cHsrpGrpStandbyRouter
137 "15", # cHsrpGrpStandbyState
138 "16", # cHsrpGrpVirtualMacAddr
140 "snmp_scan_function": lambda oid
: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() and oid(
141 ".1.3.6.1.4.1.9.9.106.1.1.1.0"),