mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-11 21:42:39 -04:00
81 lines
2.1 KiB
Bash
Executable File
81 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Wildcard-plugin to monitor network interfaces. To monitor an
|
|
# interface, link if_<interface> to this file. E.g.
|
|
#
|
|
# ln -s /usr/share/munin/node/plugins-auto/if_ /etc/munin/node.d/if_eth0
|
|
#
|
|
# ...will monitor eth0.
|
|
#
|
|
# Any device found in /usr/bin/netstat can be monitored.
|
|
#
|
|
# $Log: if_.in,v $
|
|
# Revision 1.1.1.1 2006/06/04 20:53:57 he
|
|
# Import the client version of the Munin system monitoring/graphing
|
|
# tool -- project homepage is at http://munin.sourceforge.net/
|
|
#
|
|
# This package has added support for NetBSD, via a number of new plugin
|
|
# scripts where specific steps needs to be taken to collect information.
|
|
#
|
|
# I also modified the ntp_ plugin script to make it possible to not
|
|
# plot the NTP poll delay, leaving just jitter and offset, which IMO
|
|
# produces a more telling graph.
|
|
#
|
|
#
|
|
#
|
|
# Magic markers (optional - used by munin-config and some installation
|
|
# scripts):
|
|
#
|
|
#%# family=auto
|
|
#%# capabilities=autoconf suggest
|
|
|
|
|
|
INTERFACE=`basename $0 | sed 's/^if_//g'`
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
if [ -x /usr/bin/netstat ]; then
|
|
echo yes
|
|
exit 0
|
|
else
|
|
echo "no (/usr/bin/netstat not found)"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
if [ -x /usr/bin/netstat ]; then
|
|
netstat -i -b | sed -n -e '/^faith/d' -e '/^lo0/d' -e '/<Link.*>/s/\** .*//p'
|
|
exit 0
|
|
else
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "graph_order rbytes obytes"
|
|
echo "graph_title $INTERFACE traffic"
|
|
echo 'graph_args --base 1000'
|
|
echo 'graph_vlabel bits per ${graph_period} in (-) / out (+)'
|
|
echo 'graph_category network'
|
|
echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes."
|
|
|
|
echo 'rbytes.label received'
|
|
echo 'rbytes.type COUNTER'
|
|
echo 'rbytes.graph no'
|
|
echo 'rbytes.cdef rbytes,8,*'
|
|
|
|
echo 'obytes.label bps'
|
|
echo 'obytes.type COUNTER'
|
|
echo 'obytes.negative rbytes'
|
|
echo 'obytes.cdef obytes,8,*'
|
|
echo "obytes.info Traffic sent (+) and received (-) on the $INTERFACE network interface."
|
|
exit 0
|
|
fi;
|
|
|
|
/usr/bin/netstat -i -b -I $INTERFACE | awk '
|
|
/<Link.*>/ {
|
|
print "rbytes.value ", $5;
|
|
print "obytes.value ", $6;
|
|
}'
|