Module: check_mk
Branch: master
Commit: f0b850bbb846ab9f775ade85a0754f691de215a1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0b850bbb846ab…
Author: Florian Heigl <floh(a)Klappstuhl.(none)>
Date: Fri Feb 25 09:50:29 2011 +0100
This version should correctly handle all devices handled in the h3clanSw mib.
---
checks/h3c_lanswitch_cpu | 95 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 81 insertions(+), 14 deletions(-)
diff --git a/checks/h3c_lanswitch_cpu b/checks/h3c_lanswitch_cpu
index 5422d7a..7a5e6c6 100644
--- a/checks/h3c_lanswitch_cpu
+++ b/checks/h3c_lanswitch_cpu
@@ -1,33 +1,100 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 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-
+# ails. 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.
+# Florian Heigl <fh(a)mathias-kettner.de>
+# check for switches using H3C lanswitch MIB
+#
+#
+# on standalone switches (SS500-EL, etc) we will get stats per cpu.
+#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.1 = Gauge32: 11
+# the id for the CPU will be "65536". The unit Id display will show
'1'.
+#
+# on multi-unit stacks (SS5500-EL, etc) we will get stats per cpu in each switch.
+# the table id for the CPU is (unitId*65536)+0.
+#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.65536 = Gauge32: 11
+#
+# on multi-slot switches (SS8800 etc) we will get stats for each card.
+#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.0 = Gauge32: 11
+#[...]
+#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.12 = Gauge32: 16
+#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.13 = Gauge32: 16
# Reasonably low warning and crit levels
h3c_lanswitch_cpu_default_levels = (50, 75)
def inventory_h3c_lanswitch_cpu(checkname, info):
- return [ ( int(line[0]) / 65536 , "h3c_lanswitch_cpu_default_levels" ) for
line in info ]
+ return [ (h3c_lanswitch_cpu_genitem(line[0]),
"h3c_lanswitch_cpu_default_levels") for line in info ]
def check_h3c_lanswitch_cpu(item, params, info):
warn, crit = params
for line in info:
- unitid = int(line[0]) / 65536
- if unitid == item:
- util = int(line[1])
- if util > crit:
- return (2, "CRIT - Unit %d Utilization: %s%%" % (unitid, util)
)
- elif util > warn:
- return (1, "WARN - Unit %d Utilization: %s%%" % (unitid, util)
)
- else:
- return (0, "OK - Unit %d Utilization: %s%%" % (unitid, util) )
+ if h3c_lanswitch_cpu_genitem(line[0]) == item:
+ util = int(line[1])
+ infotext = (" - average usage was %d%% over last 5 minutes." % util)
+ perfdata = [ ( "Usage", util, warn, crit, 0) ]
+
+ if util > crit:
+ return (2, "CRIT" + infotext, perfdata)
+ elif util > warn:
+ return (1, "WARN" + infotext, perfdata)
+ else:
+ return (0, "OK" + infotext, perfdata)
return (3, "UNKNOWN - Unit/CPU %s not found" % item)
+# decide switch class here (stacked or standalone/modular) and make a check item for it.
+def h3c_lanswitch_cpu_genitem(item):
+ cpuid = int(item)
+# if we have a cpuid lower than 512 it is not hashed with a unit ID
+ if cpuid < 256:
+ switchid = 1
+ cputype = "Slot"
+ cpunum = cpuid
+# othwise, if above 64k it is a known stackable switch
+ elif cpuid >= 65536:
+ switchid = cpuid / 65536
+ cputype = "CPU"
+ cpunum = cpuid % 65536
+# if we end up here 3com has added another hash method.
+ else:
+ switchid = 1
+ cputype = "Unknown"
+ cpunum = cpuid
+ return ("Switch %d %s %d" % (switchid, cputype, cpunum))
+
-check_info["h3c_lanswitch_cpu"] = (check_h3c_lanswitch_cpu, "Unit CPU Util
%s", 0, inventory_h3c_lanswitch_cpu )
+check_info["h3c_lanswitch_cpu"] = (check_h3c_lanswitch_cpu, "CPU Load
%s", 1, inventory_h3c_lanswitch_cpu )
+# get only the 5-min average load.
snmp_info["h3c_lanswitch_cpu"] = \
( "1.3.6.1.4.1.43.45.1.6.1.1.1", [ OID_END, "3" ] )
-
+# just a rough match that will handle most devices.
snmp_scan_functions["h3c_lanswitch_cpu"] = \
- lambda oid: "3com superstack 4" in oid
(".1.3.6.1.2.1.1.1.0").lower()
-# alternatively: 3Com Switch 8814
+ lambda oid: oid (".1.3.6.1.2.1.1.1.0").lower().startswith('3com
s')
+
+
+