Module: check_mk
Branch: master
Commit: 7a6816344c36585bcddc3e96237056ed1a20712c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7a6816344c3658…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Feb 25 13:50:59 2014 +0100
rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network
interfaces
---
.werks/586 | 8 ++++
ChangeLog | 1 +
checkman/rmon_stats | 30 +++++++++++++
checks/rmon_stats | 75 +++++++++++++++++++++++++++++++++
pnp-templates/check_mk-rmon_stats.php | 47 +++++++++++++++++++++
5 files changed, 161 insertions(+)
diff --git a/.werks/586 b/.werks/586
new file mode 100644
index 0000000..5c17b92
--- /dev/null
+++ b/.werks/586
@@ -0,0 +1,8 @@
+Title: rmon_stats: new snmp check to gather network traffic statistics on RMON enabled
network interfaces
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393332564
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 6aa1a7c..a8528ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
* 0556 esx_vsphere_counters.diskio: now also shows disk latency
* 0583 stulz_pump: now monitors the pumps rpm in precent of maximum and gathers
performance data
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is
missing...
+ * 0586 rmon_stats: new snmp check to gather network traffic statistics on RMON
enabled network interfaces
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/rmon_stats b/checkman/rmon_stats
new file mode 100644
index 0000000..cf0f566
--- /dev/null
+++ b/checkman/rmon_stats
@@ -0,0 +1,30 @@
+title: Traffic Analysis of Network Interfaces using RMON
+agents: snmp
+catalog: hw/network/generic
+license: GPL
+distribution: check_mk
+description:
+ This check extracts data from the RMON statistics group of RMON enabled network
+ interfaces. The data are described in the Remote MONitoring MIB. Several devices
+ of various vendors are capable of supplying RMON data via SNMP, among them
+ are some CISCO devices. It may be necessary to enable RMON for every single network
+ interface you want to gather information for.
+
+ The check always returns the state {OK}. The main purpose of the check is to gather
+ network traffic statistics as performance data.
+
+item:
+ The ID of the network interface within RMON (etherStatsIndex)
+
+inventory:
+ The inventory creates one service for each network port for which RMON is activated.
+
+perfdata:
+ {bcast}: The number of broadcast packets received per second.
+ {mcast}: The number of multicast packets received per second.
+ {0-63b}: The number of octects of size 0-63 bytes
+ {64-127b}: The number of octects pre second of size 64-127 bytes
+ {128-255b}: The number of octects pre second of size 128-255 bytes
+ {256-511b}: The number of octects pre second of size 256-511 bytes
+ {512-1023b}: The number of octects pre second of size 512-1023 bytes
+ {1024-1518b}: The number of octects pre second of size 1024-1518 bytes
diff --git a/checks/rmon_stats b/checks/rmon_stats
new file mode 100644
index 0000000..d0ab8ea
--- /dev/null
+++ b/checks/rmon_stats
@@ -0,0 +1,75 @@
+#!/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.
+
+# This check extracts data from 1.3.6.1.2.1.16.1.1.1 =
+# iso(1). org(3). dod(6). internet(1). mgmt(2). mib-2(1). rmon(16).
+# statistics(1). etherStatsTable(1). etherStatsEntry(1)
+# The MIB is called RMON-MIB
+
+
+def inventory_rmon_stats(info):
+ inventory = []
+ for line in info:
+ inventory.append((line[0], None))
+ return inventory
+
+def check_rmon_stats(item, _no_params, info):
+ bytes = { 1: 'bcast', 2: 'mcast', 3: '0-63b', 4:
'64-127b', 5: '128-255b', 6: '256-511b', 7: '512-1023b',
8: '1024-1518b' }
+ perfdata = []
+ infotext = ''
+ now = time.time()
+ for line in info:
+ if line[0] == item:
+ for i, val in bytes.items():
+ octets = int(re.sub(' Packets','',line[i]))
+ timedif, rate = get_counter("%s-%s" % (item, val), now,
octets)
+ perfdata.append((val, rate, 0, 0, 0))
+ infotext += "%s=%.0f " % (val, rate)
+ infotext += 'octets/sec'
+ return 0, infotext, perfdata
+
+ return (3, "port not found")
+
+check_info["rmon_stats"] = {
+ 'check_function' : check_rmon_stats,
+ 'inventory_function' : inventory_rmon_stats,
+ 'service_description' : 'RMON Stats IF %s',
+ 'has_perfdata' : True,
+ 'snmp_info' : ('.1.3.6.1.2.1.16.1.1.1', [ #
+ '1', # etherStatsIndex = Item
+ '6', # etherStatsBroadcastPkts
+ '7', # etherStatsMulticastPkts
+ '14', # etherStatsPkts64Octets
+ '15', # etherStatsPkts65to127Octets
+ '16', # etherStatsPkts128to255Octets
+ '17', # etherStatsPkts256to511Octets
+ '18', # etherStatsPkts512to1023Octets
+ '19', # etherStatsPkts1024to1518Octets
+ ]),
+ # for the scan we need to check for any single object in the RMON tree,
+ # we choose netDefaultGateway in the hope that it will always be present
+ 'snmp_scan_function' : lambda oid:
oid(".1.3.6.1.2.1.16.19.12.0") != None,
+}
diff --git a/pnp-templates/check_mk-rmon_stats.php
b/pnp-templates/check_mk-rmon_stats.php
new file mode 100644
index 0000000..52cdcb3
--- /dev/null
+++ b/pnp-templates/check_mk-rmon_stats.php
@@ -0,0 +1,47 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+$opt[1] = "--vertical-label 'pkts/sec' -u 10 -X0 --title \"$servicedesc
on $hostname\" ";
+
+$stats = array(
+ array(1, "BCAST", "", "#777777", ""),
+ array(2, "MCAST", " ", "#a00000", ""),
+ array(3, "0-63B", " ", "#ff0000", ""),
+ array(4, "64-127B", " ", "#ffc000", "\\n"),
+ array(5, "128-255B", " ", "#f000f0", ""),
+ array(6, "256-511B", " ", "#00b0b0", ""),
+ array(7, "512-1024B", " ", "#c060ff", ""),
+ array(8, "1024-1518B", " ", "#00f040",
"\\n")
+);
+
+$def[1] = "";
+
+foreach ($stats as $entry) {
+ list($i, $stat, $spaces, $color, $nl) = $entry;
+ $def[1] .= "DEF:$stat=$RRDFILE[$i]:$DS[$i]:MAX ";
+ $def[1] .= "AREA:$stat$color:\"$stat\":STACK ";
+ $def[1] .= "GPRINT:$stat:LAST:\"$spaces%3.0lf$nl\" ";
+}
+