Révision e49b78ab
Added `traffic' plugin, to allow measure server total throughput in both IPv4 and IPv6
| plugins/network/traffic | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# -*- bash -*- |
|
| 3 |
|
|
| 4 |
: << =cut |
|
| 5 |
|
|
| 6 |
=head1 NAME |
|
| 7 |
|
|
| 8 |
traffic - Plugin to monitor the traffic (throughput) by IP protocols. |
|
| 9 |
|
|
| 10 |
=head1 CONFIGURATION |
|
| 11 |
|
|
| 12 |
No special configuration is needed. |
|
| 13 |
|
|
| 14 |
If trouble reading files, use: |
|
| 15 |
|
|
| 16 |
[traffic] |
|
| 17 |
user root |
|
| 18 |
|
|
| 19 |
=head1 AUTHORS |
|
| 20 |
|
|
| 21 |
=over |
|
| 22 |
|
|
| 23 |
=item 2012.09.20: Initial version by Arturo Borrero Gonzalez <aborrero@cica.es> |
|
| 24 |
|
|
| 25 |
=back |
|
| 26 |
|
|
| 27 |
=head1 LICENSE |
|
| 28 |
|
|
| 29 |
GPLv2 |
|
| 30 |
|
|
| 31 |
=head1 MAGIC MARKERS |
|
| 32 |
|
|
| 33 |
#%# family=auto |
|
| 34 |
#%# capabilities=autoconf |
|
| 35 |
|
|
| 36 |
=cut |
|
| 37 |
|
|
| 38 |
|
|
| 39 |
if [ "$1" == "config" ] |
|
| 40 |
then |
|
| 41 |
cat <<'EOF' |
|
| 42 |
graph_title Throughput by IP protocol |
|
| 43 |
graph_vlabel bits per ${graph_period}
|
|
| 44 |
graph_category network |
|
| 45 |
graph_args --base 1000 --upper-limit 100 -l 0 |
|
| 46 |
IPv4.label IPv4 bps |
|
| 47 |
IPv4.min 0 |
|
| 48 |
IPv4.type DERIVE |
|
| 49 |
IPv4.draw AREA |
|
| 50 |
IPv6.label IPv6 bps |
|
| 51 |
IPv6.min 0 |
|
| 52 |
IPv6.type DERIVE |
|
| 53 |
IPv6.draw STACK |
|
| 54 |
EOF |
|
| 55 |
exit 0 |
|
| 56 |
fi |
|
| 57 |
|
|
| 58 |
if [ -r /proc/net/dev ] |
|
| 59 |
then |
|
| 60 |
echo "IPv4.value $(( `egrep -v bond\|lo /proc/net/dev | awk -F' ' '{print $2"+"$10}' | grep [0-9] | paste -sd+ | bc` * 8 ))"
|
|
| 61 |
else |
|
| 62 |
echo "IPv4.value 0" |
|
| 63 |
echo "W: Unable to read /proc/net/dev" >&2 |
|
| 64 |
fi |
|
| 65 |
|
|
| 66 |
if [ -r /proc/net/snmp6 ] |
|
| 67 |
then |
|
| 68 |
echo "IPv6.value $(( `egrep Ip6InOctets\|Ip6OutOctets /proc/net/snmp6 | awk -F' ' '{print $2}' | paste -sd+ | bc` * 8 ))"
|
|
| 69 |
else |
|
| 70 |
echo "IPv6.value 0" |
|
| 71 |
echo "W: Unable to read /proc/net/snmp6" >&2 |
|
| 72 |
fi |
|
| 73 |
|
|
| 74 |
exit 0 |
|
Formats disponibles : Unified diff