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.2.9 = STRING: "carp0"
31 #.1.3.6.1.4.1.3137.2.1.2.1.2.10 = STRING: "carp1"
32 #.1.3.6.1.4.1.3137.2.1.2.1.4.9 = INTEGER: 2
33 #.1.3.6.1.4.1.3137.2.1.2.1.4.10 = INTEGER: 2
34 #.1.3.6.1.4.1.3137.2.1.2.1.7.9 = INTEGER: 2
35 #.1.3.6.1.4.1.3137.2.1.2.1.7.10 = INTEGER: 2
38 def inventory_genua_carp(info
):
41 # remove empty elements due to two alternative enterprise ids in snmp_info
42 info
= filter(None, info
)
45 for ifName
, _ifLinkState
, ifCarpState
in info
[0]:
46 if ifCarpState
in ["0", "1", "2"]:
47 inventory
.append((ifName
, None))
51 def genua_linkstate(st
):
59 return names
.get(st
, st
)
62 def genua_carpstate(st
):
68 return names
.get(st
, st
)
71 def check_genua_carp(item
, _no_params
, info
):
73 # remove empty elements due to two alternative enterprise ids in snmp_info
74 info
= filter(None, info
)
77 return (3, "Invalid Output from Agent")
83 prefix
= "Cluster test: "
85 prefix
= "Node test: "
87 # Loop over all nodes, just one line if not a cluster
89 # Loop over interfaces on node
90 for ifName
, ifLinkState
, ifCarpState
in line
:
91 ifLinkStateStr
= genua_linkstate(str(ifLinkState
))
92 ifCarpStateStr
= genua_carpstate(str(ifCarpState
))
93 # is inventorized interface in state carp master ?
94 if ifName
== item
and ifCarpState
== "2":
100 output
+= "node in carp state %s with IfLinkState %s" \
101 % (ifCarpStateStr
,ifLinkStateStr
)
103 if ifLinkState
== "2":
105 elif ifLinkState
== "1":
107 elif ifLinkState
in ["0", "3"]:
113 output
= "%d nodes in carp state %s on cluster with %d nodes" \
114 % (masters
,ifCarpStateStr
,nodes
)
115 # look for non-masters, only interesting if no cluster
116 elif ifName
== item
and nodes
== 1:
117 output
= "node in carp state %s with IfLinkState %s" \
118 % (ifCarpStateStr
,ifLinkStateStr
)
120 if ifCarpState
== "1" and ifLinkState
== "1":
125 # no masters found in cluster
126 if nodes
> 1 and masters
== 0:
128 output
= "No master found on cluster with %d nodes" % nodes
130 output
= prefix
+ output
131 return (state
, output
)
134 check_info
['genua_carp'] = {
135 "inventory_function": inventory_genua_carp
,
136 "check_function": check_genua_carp
,
137 "service_description": "Carp Interface %s",
140 ".1.3.6.1.4.1.3137.2.1.2",
143 "1.4", # "ifLinkState"
144 "1.7", # "ifCarpState"
147 ".1.3.6.1.4.1.3717.2.1.2",
150 "1.4", # "ifLinkState"
151 "1.7", # "ifCarpState"
154 "snmp_scan_function": scan_genua
,
155 "includes": ["genua.include"],