Module: check_mk
Branch: master
Commit: ec55fff26bd471dab52d15608fbe017a4278f589
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ec55fff26bd471…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Sep 11 15:32:30 2018 +0200
6465 cisco_stack: New check to monitor the status of Cisco stack switches
Change-Id: I46afa65886d1ef0f7bd2a8d0edfac7c397cbc5aa
---
.werks/6465 | 10 +++
checkman/cisco_stack | 13 ++++
checks/cisco_stack | 121 +++++++++++++++++++++++++++++++
cmk/gui/plugins/wato/check_parameters.py | 26 +++++++
4 files changed, 170 insertions(+)
diff --git a/.werks/6465 b/.werks/6465
new file mode 100644
index 0000000..475ce4f
--- /dev/null
+++ b/.werks/6465
@@ -0,0 +1,10 @@
+Title: cisco_stack: New check to monitor the status of Cisco stack switches
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1536672721
+Class: feature
+
+
diff --git a/checkman/cisco_stack b/checkman/cisco_stack
new file mode 100644
index 0000000..0f65218
--- /dev/null
+++ b/checkman/cisco_stack
@@ -0,0 +1,13 @@
+title: CISCO Stack Switches: Stack Switch States
+agents: snmp
+catalog: hw/network/cisco
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the stack states of switches.
+
+item:
+ The stack switch number.
+
+inventory:
+ One service per switch is created.
diff --git a/checks/cisco_stack b/checks/cisco_stack
new file mode 100644
index 0000000..319de05
--- /dev/null
+++ b/checks/cisco_stack
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+factory_settings["cisco_stack"] = {
+ "waiting" : 0,
+ "progressing" : 0,
+ "added" : 0,
+ "ready" : 0,
+ "sdmMismatch" : 1,
+ "verMismatch" : 1,
+ "featureMismatch" : 1,
+ "newMasterInit" : 0,
+ "provisioned" : 0,
+ "invalid" : 2,
+ "removed" : 2,
+}
+
+
+def parse_cisco_stack(info):
+
+ switch_state_names = {
+ "1" : "waiting",
+ "2" : "progressing",
+ "3" : "added",
+ "4" : "ready",
+ "5" : "sdmMismatch",
+ "6" : "verMismatch",
+ "7" : "featureMismatch",
+ "8" : "newMasterInit",
+ "9" : "provisioned",
+ "10" : "invalid",
+ "11" : "removed",
+ }
+
+ switch_role_names = {
+ "1" : "master",
+ "2" : "member",
+ "3" : "notMember",
+ }
+
+ parsed = {}
+ for line in info:
+ parsed[line[0]] = {
+ "switch_role" : switch_role_names.get(line[1],
"unknown"),
+ "switch_state" : switch_state_names.get(line[2],
"unknown"),
+ }
+ return parsed
+
+
+def inventory_cisco_stack(parsed):
+ for item in parsed:
+ yield item, {}
+
+
+def check_cisco_stack(item, params, parsed):
+
+ switch_state_descriptions = {
+ "waiting" : "Waiting for other switches to come online",
+ "progressing" : "Master election or mismatch checks in
progress",
+ "added" : "Added to stack",
+ "ready" : "Ready",
+ "sdmMismatch" : "SDM template mismatch",
+ "verMismatch" : "OS version mismatch",
+ "featureMismatch" : "Configured feature mismatch",
+ "newMasterInit" : "Waiting for new master initialization",
+ "provisioned" : "Not an active member of the stack",
+ "invalid" : "State machine in invalid state",
+ "removed" : "Removed from stack",
+ }
+
+ data = parsed.get(item)
+ if data is None:
+ return
+
+ switch_state = data["switch_state"]
+ switch_role = data["switch_role"]
+
+ status = params.get(data["switch_state"], 3)
+ infotext = "Switch state: %s (%s), switch role: %s" %
(switch_state_descriptions.get(switch_state, "Unknown"),
+ switch_state, switch_role)
+ return status, infotext
+
+
+check_info['cisco_stack'] = {
+ 'default_levels_variable' : 'cisco_stack',
+ 'parse_function' : parse_cisco_stack,
+ 'inventory_function' : inventory_cisco_stack,
+ 'check_function' : check_cisco_stack,
+ 'service_description' : 'Switch stack status %s',
+ 'snmp_info' : ('.1.3.6.1.4.1.9.9.500.1.2.1.1', [
+ "1", # cswSwitchNumCurrent
+ "3", # cswSwitchRole
+ "6", # cswSwitchState
+ ]),
+ 'snmp_scan_function' : lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.9.1.1208"),
+ 'group' : 'cisco_stack',
+}
diff --git a/cmk/gui/plugins/wato/check_parameters.py
b/cmk/gui/plugins/wato/check_parameters.py
index d9fe3bc..086c13c 100755
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -891,6 +891,32 @@ register_check_parameters(
"dict",
)
+register_check_parameters(
+ subgroup_networking,
+ "cisco_stack",
+ _("Cisco Stack Switch Status"),
+ Dictionary(
+ elements=[
+ ("waiting", MonitoringState(title=_(u"waiting"),
default_value=0, help=_(u"Waiting for other switches to come online"))),
+ ("progressing", MonitoringState(title=_(u"progressing"),
default_value=0, help=_(u"Master election or mismatch checks in progress"))),
+ ("added", MonitoringState(title=_(u"added"),
default_value=0, help=_(u"Added to stack"))),
+ ("ready", MonitoringState(title=_(u"ready"),
default_value=0, help=_(u"Ready"))),
+ ("sdmMismatch", MonitoringState(title=_(u"sdmMismatch"),
default_value=1, help=_(u"SDM template mismatch"))),
+ ("verMismatch", MonitoringState(title=_(u"verMismatch"),
default_value=1, help=_(u"OS version mismatch"))),
+ ("featureMismatch",
MonitoringState(title=_(u"featureMismatch"), default_value=1,
help=_(u"Configured feature mismatch"))),
+ ("newMasterInit",
MonitoringState(title=_(u"newMasterInit"), default_value=0,
help=_(u"Waiting for new master initialization"))),
+ ("provisioned", MonitoringState(title=_(u"provisioned"),
default_value=0, help=_(u"Not an active member of the stack"))),
+ ("invalid", MonitoringState(title=_(u"invalid"),
default_value=2, help=_(u"State machine in invalid state"))),
+ ("removed", MonitoringState(title=_(u"removed"),
default_value=2, help=_(u"Removed from stack"))),
+ ],
+ optional_keys=[],
+ ),
+ TextAscii(
+ title=_("Switch number"),
+ ),
+ "dict",
+)
+
#.
# .--Inventory-----------------------------------------------------------.
# | ___ _ |