2012-09-20 17:30:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- bash -*-
|
|
|
|
|
|
|
|
: << =cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
traffic - Plugin to monitor the traffic (throughput) by IP protocols.
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
No special configuration is needed.
|
|
|
|
|
|
|
|
If trouble reading files, use:
|
|
|
|
|
|
|
|
[traffic]
|
|
|
|
user root
|
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item 2012.09.20: Initial version by Arturo Borrero Gonzalez <aborrero@cica.es>
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
GPLv2
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" == "config" ]
|
|
|
|
then
|
|
|
|
cat <<'EOF'
|
|
|
|
graph_title Throughput by IP protocol
|
|
|
|
graph_vlabel bits per ${graph_period}
|
|
|
|
graph_category network
|
|
|
|
graph_args --base 1000 --upper-limit 100 -l 0
|
|
|
|
IPv4.label IPv4 bps
|
|
|
|
IPv4.min 0
|
|
|
|
IPv4.type DERIVE
|
|
|
|
IPv4.draw AREA
|
|
|
|
IPv6.label IPv6 bps
|
|
|
|
IPv6.min 0
|
|
|
|
IPv6.type DERIVE
|
|
|
|
IPv6.draw STACK
|
2012-09-21 10:50:29 +02:00
|
|
|
total.label Total bps
|
|
|
|
total.min 0
|
|
|
|
total.type DERIVE
|
|
|
|
total.draw LINE1
|
2012-09-20 17:30:18 +02:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-09-21 10:50:29 +02:00
|
|
|
|
2012-09-20 17:30:18 +02:00
|
|
|
if [ -r /proc/net/dev ]
|
|
|
|
then
|
2012-09-25 14:03:59 +02:00
|
|
|
ipv4=$( echo "`egrep -v bond\|lo /proc/net/dev | awk -F' ' '{print $2+$10}' | paste -sd+ | bc` * 8" | bc )
|
2012-09-21 10:50:29 +02:00
|
|
|
echo "IPv4.value $ipv4"
|
2012-09-20 17:30:18 +02:00
|
|
|
else
|
2012-09-21 10:50:29 +02:00
|
|
|
echo "IPv4.value 0"
|
|
|
|
echo "W: Unable to read /proc/net/dev" >&2
|
2012-09-20 17:30:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -r /proc/net/snmp6 ]
|
|
|
|
then
|
2012-09-25 14:03:59 +02:00
|
|
|
ipv6=$( echo "`egrep Ip6InOctets\|Ip6OutOctets /proc/net/snmp6 | awk -F' ' '{print $2}' | paste -sd+ | bc` * 8" | bc )
|
2012-09-21 10:50:29 +02:00
|
|
|
echo "IPv6.value $ipv6"
|
2012-09-20 17:30:18 +02:00
|
|
|
else
|
2012-09-21 10:50:29 +02:00
|
|
|
echo "IPv6.value 0"
|
|
|
|
echo "W: Unable to read /proc/net/snmp6" >&2
|
2012-09-20 17:30:18 +02:00
|
|
|
fi
|
2012-09-21 10:50:29 +02:00
|
|
|
echo "total.value $( echo $ipv4 + $ipv6 | bc )"
|
2012-09-20 17:30:18 +02:00
|
|
|
|
|
|
|
exit 0
|
2012-09-21 10:50:29 +02:00
|
|
|
|