Add modified if_ and if_packets_ munin plugin that uses ifcounters instead of netstat
This commit is contained in:
parent
6112194e8e
commit
1aac06d3e9
62
if_
Executable file
62
if_
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
#
|
||||
# Wildcard-plugin to monitor network interfaces. To monitor an
|
||||
# interface, link if_<interface> to this file. E.g.
|
||||
#
|
||||
# ln -s /usr/local/share/munin/plugins/if_ /usr/local/etc/munin/plugins/if_em0
|
||||
#
|
||||
# ...will monitor em0 interface.
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and some installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
INTERFACE=${0##*if_}
|
||||
IFCOUNTERS="/usr/local/bin/ifcounters"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x /sbin/ifconfig -o -x ${IFCOUNTERS} ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (${IFCOUNTERS} not found)"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "suggest" ]; then
|
||||
if [ -x /sbin/ifconfig ]
|
||||
then
|
||||
ifconfig -l | sed -Ee 's/[[:<:]](pfsync|faith|pf(log|sync)|lo|plip|carp|enc|fwe)[^ ]*//g' | xargs -n 1 echo
|
||||
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. IMPORTANT: Since the data source for this plugin use 32bit counters, this plugin is really unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that this plugin is unsuitable for most production environments."
|
||||
echo 'rbytes.label received'
|
||||
echo 'rbytes.type DERIVE'
|
||||
echo 'rbytes.graph no'
|
||||
echo 'rbytes.cdef rbytes,8,*'
|
||||
echo 'rbytes.min 0'
|
||||
echo 'obytes.label bps'
|
||||
echo 'obytes.type DERIVE'
|
||||
echo 'obytes.negative rbytes'
|
||||
echo 'obytes.cdef obytes,8,*'
|
||||
echo 'obytes.min 0'
|
||||
echo 'obytes.draw AREA'
|
||||
echo "obytes.info Traffic sent (+) and received (-) on the $INTERFACE network interface."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${IFCOUNTERS} -b ${INTERFACE}
|
65
if_packets_
Executable file
65
if_packets_
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
#
|
||||
# Wildcard-plugin to monitor network interfaces. To monitor an
|
||||
# interface, link if_packets_<interface> to this file. E.g.
|
||||
#
|
||||
# ln -s /usr/local/share/munin/plugins/if_packets_ /usr/local/etc/munin/plugins/if_packets_em0
|
||||
#
|
||||
# ...will monitor eth0 interface.
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and some installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
INTERFACE=${0##*if_packets_}
|
||||
IFCOUNTERS="/usr/local/bin/ifcounters"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x /sbin/ifconfig -o -x ${IFCOUNTERS} ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (${IFCOUNTERS} not found)"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "suggest" ]; then
|
||||
if [ -x /sbin/ifconfig ]
|
||||
then
|
||||
ifconfig -l | sed -Ee 's/[[:<:]](pfsync|faith|pf(log|sync)|lo|plip|carp|enc|fwe)[^ ]*//g' | xargs -n 1 echo
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_order rpackets opackets"
|
||||
echo "graph_title $INTERFACE pps"
|
||||
echo 'graph_args --base 1000'
|
||||
echo 'graph_vlabel packets per ${graph_period} in (-) / out (+)'
|
||||
echo 'graph_category network'
|
||||
echo "graph_info This graph shows the packets counter of the $INTERFACE network interface. Please note that the traffic is shown in packets per second."
|
||||
echo 'rpackets.label received'
|
||||
echo 'rpackets.type COUNTER'
|
||||
echo 'rpackets.graph no'
|
||||
|
||||
echo 'rpackets.min 0'
|
||||
echo 'opackets.label pps'
|
||||
echo 'opackets.type COUNTER'
|
||||
echo 'opackets.colour COLOUR19'
|
||||
echo 'opackets.draw AREA'
|
||||
echo 'opackets.negative rpackets'
|
||||
|
||||
echo 'opackets.min 0'
|
||||
echo "opackets.info Packets sent (+) and received (-) on the $INTERFACE network interface."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${IFCOUNTERS} -p ${INTERFACE}
|
||||
|
Loading…
x
Reference in New Issue
Block a user