2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/network/proc_netstat

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2014-07-08 05:02:13 +02:00
#!/bin/sh
# -*- sh -*-
#
# Plugin to monitor network connection activity using a subset of data from /proc/net/netstat
#
# Parameters:
#
# config (required)
# autoconf (optional - only used by munin-config)
#
# Environment variables (optional):
#
# IGNORED_FIELDS: comma-separated list of regexs for fields to ignore
#
# Author: Ted Dumitrescu (ted@mixpanel.com, webdev@cmme.org)
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#%# family=auto
#%# capabilities=autoconf
NETSTATS="/proc/net/netstat"
if [ -z $IGNORED_FIELDS ]; then
IGNORED_FIELDS='TW\.,TCPPrequeued,TCPDirectCopy,TCPHPHits,TCPPureAcks,TCPHPAcks,TCPRcvCoalesce'
fi
TO_REMOVE=`echo $IGNORED_FIELDS | sed 's/,/\\\|/g'`
STRIP_OUTPUT="/\($TO_REMOVE\)/d"
if [ "$1" = "autoconf" ]; then
if [ -r $NETSTATS ]; then
echo yes
else
echo no
fi
exit 0
2014-07-08 05:02:13 +02:00
fi
if [ "$1" = "config" ]; then
echo 'graph_title Netstat'
echo 'graph_args -l 0 --base 1000'
echo 'graph_category network'
echo 'graph_period second'
echo 'graph_info TcpExt stats'
awk 'NR < 2 { for (i=2; i<=NF; i++) { printf("%s.label %s\n%s.type DERIVE\n%s.min 0\n", $i, $i, $i, $i); } }' $NETSTATS | sed "$STRIP_OUTPUT"
exit 0
fi
awk 'NR < 2 { for (i=2; i<=NF; i++) { fn[i]=$i; }; getline; for (i=2; i<=NF; i++) { printf("%s.value %s\n", fn[i], $i); } }' $NETSTATS | sed "$STRIP_OUTPUT"