Module: check_mk
Branch: master
Commit: 91d72c1a19ca9fbc21b5cb34c7de8413fdca24e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=91d72c1a19ca9f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Apr 3 17:03:12 2013 +0200
if64_tplink: special new check for TP Link switches with broken SNMP output
---
ChangeLog | 1 +
checks/if.include | 7 ++++
checks/if64 | 1 +
checks/if64_tplink | 53 ++++++++++++++++++++++++++++++++
pnp-templates/check_mk-if64_tplink.php | 1 +
web/plugins/perfometer/check_mk.py | 1 +
6 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a8d481e..af77b74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
* smart.stats: rewrote check. Please reinventorize. Error counters are now
snapshotted during inventory.
* smart.temp: add WATO configuration
+ * if64_tplink: special new check for TP Link switches with broken SNMP output
Notifications:
* notify.py: unique spoolfiles name no longer created with uuid
diff --git a/checks/if.include b/checks/if.include
index 9667a3f..6943db1 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -126,6 +126,11 @@ def inventory_if_common(info):
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
+ # Fix bug in TP Link switches
+ ifSpeed = saveint(ifSpeed)
+ if ifSpeed > 9000000 * 100 * 1000:
+ ifSpeed /= 1000000
+
# compute item now - also for unmonitored ports - in order to see if it is
unique.
if uses_description and ifDescr:
item = ifDescr
@@ -364,6 +369,8 @@ def check_if_common_single(item, params, info, force_counter_wrap =
False):
# prepare reference speed for computing relative bandwidth usage
speed = saveint(ifSpeed)
if speed:
+ if speed > 9 * 1000 * 1000 * 1000 * 1000:
+ speed /= (1000 * 1000)
ref_speed = speed / 8.0
elif targetspeed:
ref_speed = targetspeed / 8.0
diff --git a/checks/if64 b/checks/if64
index fe41b47..2cc9aa8 100644
--- a/checks/if64
+++ b/checks/if64
@@ -71,6 +71,7 @@ check_info["if64"] = {
]),
'snmp_scan_function': \
lambda oid: "LANCOM" not in oid("1.3.6.1.2.1.1.1.0") and \
+ ".4.1.11863." not in oid(".1.3.6.1.2.1.1.2.0")
and \
(not if64_disabled(g_hostname)) and \
oid(".1.3.6.1.2.1.31.1.1.1.6.*") != None,
'group': 'if',
diff --git a/checks/if64_tplink b/checks/if64_tplink
new file mode 100644
index 0000000..07e013d
--- /dev/null
+++ b/checks/if64_tplink
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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.
+
+check_includes['if64_tplink'] = [ "if64", "if.include" ]
+check_info["if64_tplink"] = dict(check_info["if64"])
+check_info["if64_tplink"]["snmp_info"] = ( ".1.3.6.1", [
+ "2.1.2.2.1.1", # ifIndex 0
+ "2.1.2.2.1.2", # ifDescr 1
+ "2.1.2.2.1.3", # ifType 2
+ "2.1.31.1.1.1.15", # ifHighSpeed .. 1000 means 1GBit
+ "2.1.2.2.1.8", # ifOperStatus 4
+ "2.1.31.1.1.1.6", # ifHCInOctets 5
+ "2.1.31.1.1.1.7", # ifHCInUcastPkts 6
+ "2.1.31.1.1.1.8", # ifHCInMulticastPkts 7
+ "2.1.31.1.1.1.9", # ifHCInBroadcastPkts 8
+ "2.1.2.2.1.13", # ifInDiscards 9
+ "2.1.2.2.1.14", # ifInErrors 10
+ "2.1.31.1.1.1.10", # ifHCOutOctets 11
+ "2.1.31.1.1.1.11", # ifHCOutUcastPkts 12
+ "2.1.31.1.1.1.12", # ifHCOutMulticastPkts 13
+ "2.1.31.1.1.1.13", # ifHCOutBroadcastPkts 14
+ "2.1.2.2.1.19", # ifOutDiscards 15
+ "2.1.2.2.1.20", # ifOutErrors 16
+ "2.1.2.2.1.21", # ifOutQLen 17
+ "4.1.11863.1.1.3.2.1.1.1.1.2", # special for TP Link
+ "2.1.2.2.1.6", # ifPhysAddress 19
+ ])
+check_info["if64_tplink"]["snmp_scan_function"] = \
+ lambda oid: ".4.1.11863." in oid(".1.3.6.1.2.1.1.2.0") and
\
+ oid(".1.3.6.1.2.1.31.1.1.1.6.*") != None
diff --git a/pnp-templates/check_mk-if64_tplink.php
b/pnp-templates/check_mk-if64_tplink.php
new file mode 120000
index 0000000..9a34dce
--- /dev/null
+++ b/pnp-templates/check_mk-if64_tplink.php
@@ -0,0 +1 @@
+check_mk-if.php
\ No newline at end of file
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 907d719..f959cf6 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -313,6 +313,7 @@ def perfometer_check_mk_cisco_qos(row, check_command, perf_data):
perfometers["check_mk-if"] = perfometer_check_mk_if
perfometers["check_mk-if64"] = perfometer_check_mk_if
+perfometers["check_mk-if64_tplink"] = perfometer_check_mk_if
perfometers["check_mk-vms_if"] = perfometer_check_mk_if
perfometers["check_mk-if_lancom"] = perfometer_check_mk_if
perfometers["check_mk-lnx_if"] = perfometer_check_mk_if