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.
27 # Example Agent Output:
30 # .1.3.6.1.4.1.3137.2.1.2.1.1.9 = INTEGER: 9
31 # .1.3.6.1.4.1.3137.2.1.2.1.1.10 = INTEGER: 10
32 # .1.3.6.1.4.1.3137.2.1.2.1.2.9 = STRING: "carp0"
33 # .1.3.6.1.4.1.3137.2.1.2.1.2.10 = STRING: "carp1"
34 # .1.3.6.1.4.1.3137.2.1.2.1.3.9 = INTEGER: 5
35 # .1.3.6.1.4.1.3137.2.1.2.1.3.10 = INTEGER: 5
36 # .1.3.6.1.4.1.3137.2.1.2.1.4.9 = INTEGER: 2
37 # .1.3.6.1.4.1.3137.2.1.2.1.4.10 = INTEGER: 2
38 # .1.3.6.1.4.1.3137.2.1.2.1.7.9 = INTEGER: 2
39 # .1.3.6.1.4.1.3137.2.1.2.1.7.10 = INTEGER: 2
42 def inventory_genua_state(info
):
43 # remove empty elements due to two alternative enterprise ids in snmp_info
44 info
= filter(None, info
)
47 for _ifIndex
, _ifName
, _ifType
, _ifLinkState
, ifCarpState
in info
[0]:
48 if ifCarpState
in ["0", "1", "2"]:
50 # inventorize only if we find at least two carp interfaces
56 def genua_state_str(st
):
62 return names
.get(st
, st
)
65 def check_genua_state(item
, _no_params
, info
):
67 # remove empty elements due to two alternative enterprise ids in snmp_info
68 info
= filter(None, info
)
70 return (3, "Invalid Output from Agent")
75 for ifIndex
, ifName
, ifType
, ifLinkState
, ifCarpState
in info
[0]:
77 carp_info
.append((ifIndex
, ifName
, ifType
, ifLinkState
, ifCarpState
))
79 # critical if the carp interfaces dont have the same state
80 carp_states
= [0, 0, 0]
81 for i
, elem
in enumerate(carp_info
):
82 carp_states
[int(elem
[4])] += 1
83 if carp_info
[0][4] != elem
[4]:
86 output
= "Number of carp IFs in states "
87 for i
in ('0', '1', '2'):
88 output
+= genua_state_str(i
)
89 output
+= ":%d " % carp_states
[int(i
)]
91 return (state
, output
)
94 check_info
['genua_state_correlation'] = {
95 "inventory_function": inventory_genua_state
,
96 "check_function": check_genua_state
,
97 "service_description": "Carp Correlation",
100 ".1.3.6.1.4.1.3717.2.1.2",
105 "1.4", # "ifLinkState"
106 "1.7", # "ifCarpState"
109 ".1.3.6.1.4.1.3137.2.1.2",
114 "1.4", # "ifLinkState"
115 "1.7", # "ifCarpState"
118 "snmp_scan_function": scan_genua
,
119 "includes": ["genua.include"],