Module: check_mk
Branch: master
Commit: 21b266c7d03f57898e517b83e3270d1a10ce8282
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=21b266c7d03f57…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Mar 21 11:08:31 2018 +0100
5752 cisco_stackpower: only inventorize enabled ports, show operational status in service
output
Change-Id: Ia85a73f72a08bb46632d265b82f9b60ccabb5e8a
---
.werks/5752 | 10 +++++
checks/cisco_stackpower | 102 +++++++++++++++++++++++++++++-------------------
2 files changed, 71 insertions(+), 41 deletions(-)
diff --git a/.werks/5752 b/.werks/5752
new file mode 100644
index 0000000..2ee64a7
--- /dev/null
+++ b/.werks/5752
@@ -0,0 +1,10 @@
+Title: cisco_stackpower: only inventorize enabled ports, show operational status in
service output
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1521626667
+Class: feature
+
+
diff --git a/checks/cisco_stackpower b/checks/cisco_stackpower
index 9478de1..87432eb 100644
--- a/checks/cisco_stackpower
+++ b/checks/cisco_stackpower
@@ -24,55 +24,75 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# example:
-# 1001 stack member and master
-# 2001 stack member
-# 3001 stack member
-# 4001 stack member
-
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.0 Port 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.1001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.1 Port 2 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.1001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.0 Port 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.2001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.1 Port 2 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.2001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.0 Port 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.3001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.1 Port 2 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.3001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.4001.0 Port 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.4001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.4001.1 Port 2 -->
CISCO-STACKWISE-MIB::cswStackPowerPortName.4001.1
-
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.0 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.1001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.1 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.1001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.0 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.2001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.1 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.2001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.0 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.3001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.1 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.3001.1
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.4001.0 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.4001.0
-# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.4001.1 1 -->
CISCO-STACKWISE-MIB::cswStackPowerPortLinkStatus.4001.1
-
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.1001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.1001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.2001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.2001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.3001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.2.3001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.1001.0 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.1001.1 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.2001.0 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.2001.1 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.3001.0 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.3.3001.1 "00 00 00 00 00 00 "
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.1001.0 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.1001.1 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.2001.0 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.2001.1 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.3001.0 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.4.3001.1 0
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.0 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.1 1
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.1001.0 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.1001.1 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.2001.0 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.2001.1 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.3001.0 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.6.3001.1 40
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.0 "Port 1"
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.1 "Port 2"
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.0 "Port 1"
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.1 "Port 2"
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.0 "Port 1"
+# .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.1 "Port 2"
def inventory_cisco_stackpower(info):
- return [ ("%s %s" % (oid.split(".")[0], port_name), None) \
- for oid, port_name, port_status in info ]
+ return [("%s %s" % (oid.split(".")[0], port_name), None)
+ for oid, port_oper_status, port_link_status, port_name in info
+ if port_oper_status == '1']
def check_cisco_stackpower(item, params, info):
+ map_oper_status = {
+ '1': (0, 'Port enabled'),
+ '2': (2, 'Port disabled'),
+ }
+
map_status = {
- "1" : (0, "connected and operational"),
- "2" : (2, "forced down or not connected"),
+ '1': (0, 'Status: connected and operational'),
+ '2': (2, 'Status: forced down or not connected'),
}
- for oid, port_name, port_status in info:
- if "%s %s" % (oid.split(".")[0], port_name) == item:
- state, state_readable = map_status[port_status]
- return state, "link status: %s" % state_readable
+
+ for oid, port_oper_status, port_link_status, port_name in info:
+ if item == '%s %s' % (oid.split(".")[0], port_name):
+ yield map_oper_status[port_oper_status]
+ yield map_status[port_link_status]
check_info['cisco_stackpower'] = {
- 'inventory_function' : inventory_cisco_stackpower,
- 'check_function' : check_cisco_stackpower,
- 'service_description' : 'Stackpower Interface %s',
- 'snmp_info' : (".1.3.6.1.4.1.9.9.500.1.3.2.1", [
- OID_END,
- "7", # cswStackPowerPortName
- "5", # cswStackPowerPortLinkStatus
- ]),
- 'snmp_scan_function' : lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.9.1.516"),
+ 'inventory_function' : inventory_cisco_stackpower,
+ 'check_function' : check_cisco_stackpower,
+ 'service_description': 'Stackpower Interface %s',
+ 'snmp_info' : ('.1.3.6.1.4.1.9.9.500.1.3.2.1', [
+ OID_END,
+ '2', # cswStackPowerPortOperStatus
+ '5', # cswStackPowerPortLinkStatus
+ '7', # cswStackPowerPortName
+ ]),
+ 'snmp_scan_function' : lambda oid:
oid('.1.3.6.1.2.1.1.2.0').startswith('.1.3.6.1.4.1.9.1.516'),
}