2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2018 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 factory_settings
["cisco_stack"] = {
42 def parse_cisco_stack(info
):
44 switch_state_names
= {
51 "7": "featureMismatch",
67 "switch_role": switch_role_names
.get(line
[1], "unknown"),
68 "switch_state": switch_state_names
.get(line
[2], "unknown"),
73 def inventory_cisco_stack(parsed
):
78 def check_cisco_stack(item
, params
, parsed
):
80 switch_state_descriptions
= {
81 "waiting": "Waiting for other switches to come online",
82 "progressing": "Master election or mismatch checks in progress",
83 "added": "Added to stack",
85 "sdmMismatch": "SDM template mismatch",
86 "verMismatch": "OS version mismatch",
87 "featureMismatch": "Configured feature mismatch",
88 "newMasterInit": "Waiting for new master initialization",
89 "provisioned": "Not an active member of the stack",
90 "invalid": "State machine in invalid state",
91 "removed": "Removed from stack",
94 data
= parsed
.get(item
)
98 switch_state
= data
["switch_state"]
99 switch_role
= data
["switch_role"]
101 status
= params
.get(data
["switch_state"], 3)
102 infotext
= "Switch state: %s (%s), switch role: %s" % (switch_state_descriptions
.get(
103 switch_state
, "Unknown"), switch_state
, switch_role
)
104 return status
, infotext
107 check_info
['cisco_stack'] = {
108 'default_levels_variable': 'cisco_stack',
109 'parse_function': parse_cisco_stack
,
110 'inventory_function': inventory_cisco_stack
,
111 'check_function': check_cisco_stack
,
112 'service_description': 'Switch stack status %s',
114 '.1.3.6.1.4.1.9.9.500.1.2.1.1',
116 "1", # cswSwitchNumCurrent
118 "6", # cswSwitchState
120 'snmp_scan_function':
121 lambda oid
: (oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.9.1.1208") or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.9.1.1745")),
122 'group': 'cisco_stack',