root / plugins / network / traffic @ c3660c2a
Historique | Voir | Annoter | Télécharger (2,24 ko)
| 1 | e49b78ab | Arturo Borrero Gonzalez | #!/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 | 21fa1d24 | Michiel Holtkamp | |
| 25 | 6fcde6d8 | Michiel Holtkamp | =item 2013.01.12: Added percentage graphing by Michiel Holtkamp <michiel@supermind.nl> |
| 26 | e49b78ab | Arturo Borrero Gonzalez | |
| 27 | =back |
||
| 28 | |||
| 29 | =head1 LICENSE |
||
| 30 | |||
| 31 | GPLv2 |
||
| 32 | |||
| 33 | =head1 MAGIC MARKERS |
||
| 34 | |||
| 35 | #%# family=auto |
||
| 36 | #%# capabilities=autoconf |
||
| 37 | |||
| 38 | =cut |
||
| 39 | |||
| 40 | |||
| 41 | if [ "$1" == "config" ] |
||
| 42 | then |
||
| 43 | cat <<'EOF' |
||
| 44 | 6fcde6d8 | Michiel Holtkamp | multigraph traffic |
| 45 | e49b78ab | Arturo Borrero Gonzalez | graph_title Throughput by IP protocol |
| 46 | graph_vlabel bits per ${graph_period}
|
||
| 47 | graph_category network |
||
| 48 | graph_args --base 1000 --upper-limit 100 -l 0 |
||
| 49 | IPv4.label IPv4 bps |
||
| 50 | IPv4.min 0 |
||
| 51 | IPv4.type DERIVE |
||
| 52 | IPv4.draw AREA |
||
| 53 | IPv6.label IPv6 bps |
||
| 54 | IPv6.min 0 |
||
| 55 | IPv6.type DERIVE |
||
| 56 | IPv6.draw STACK |
||
| 57 | 09b0f002 | Arturo Borrero Gonzalez | total.label Total bps |
| 58 | total.min 0 |
||
| 59 | total.type DERIVE |
||
| 60 | total.draw LINE1 |
||
| 61 | e49b78ab | Arturo Borrero Gonzalez | EOF |
| 62 | 6fcde6d8 | Michiel Holtkamp | |
| 63 | # Adapted from http://munin-monitoring.org/wiki/PercentGraphHowto |
||
| 64 | cat <<'EOF' |
||
| 65 | multigraph traffic_percent |
||
| 66 | graph_scale no |
||
| 67 | graph_title Throughput of IP protocols by percentage |
||
| 68 | graph_vlabel Percentage |
||
| 69 | graph_order IPv4=traffic.IPv4 IPv6=traffic.IPv6 total=traffic.total IPv4_percent=traffic.total IPv6_percent=traffic.total total_percent=traffic.total |
||
| 70 | graph_category network |
||
| 71 | graph_args --upper-limit 100 -l 0 -r |
||
| 72 | IPv4.label no |
||
| 73 | IPv6.label no |
||
| 74 | total.label no |
||
| 75 | total_percent.label no |
||
| 76 | IPv4.graph no |
||
| 77 | IPv6.graph no |
||
| 78 | total.graph no |
||
| 79 | total_percent.graph no |
||
| 80 | total_percent.cdef total,0.0000001,+ |
||
| 81 | IPv4_percent.label IPv4 |
||
| 82 | IPv4_percent.cdef IPv4,total_percent,/,100,* |
||
| 83 | IPv4_percent.draw AREASTACK |
||
| 84 | IPv6_percent.label IPv6 |
||
| 85 | IPv6_percent.cdef IPv6,total_percent,/,100,* |
||
| 86 | IPv6_percent.draw AREASTACK |
||
| 87 | EOF |
||
| 88 | e49b78ab | Arturo Borrero Gonzalez | exit 0 |
| 89 | fi |
||
| 90 | |||
| 91 | 09b0f002 | Arturo Borrero Gonzalez | |
| 92 | e49b78ab | Arturo Borrero Gonzalez | if [ -r /proc/net/dev ] |
| 93 | then |
||
| 94 | f2032538 | Arturo Borrero Gonzalez | ipv4=$( echo "`egrep -v bond\|lo /proc/net/dev | awk -F' ' '{print $2+$10}' | paste -sd+ | bc` * 8" | bc )
|
| 95 | 09b0f002 | Arturo Borrero Gonzalez | echo "IPv4.value $ipv4" |
| 96 | e49b78ab | Arturo Borrero Gonzalez | else |
| 97 | 09b0f002 | Arturo Borrero Gonzalez | echo "IPv4.value 0" |
| 98 | echo "W: Unable to read /proc/net/dev" >&2 |
||
| 99 | e49b78ab | Arturo Borrero Gonzalez | fi |
| 100 | |||
| 101 | if [ -r /proc/net/snmp6 ] |
||
| 102 | then |
||
| 103 | f2032538 | Arturo Borrero Gonzalez | ipv6=$( echo "`egrep Ip6InOctets\|Ip6OutOctets /proc/net/snmp6 | awk -F' ' '{print $2}' | paste -sd+ | bc` * 8" | bc )
|
| 104 | 09b0f002 | Arturo Borrero Gonzalez | echo "IPv6.value $ipv6" |
| 105 | e49b78ab | Arturo Borrero Gonzalez | else |
| 106 | 09b0f002 | Arturo Borrero Gonzalez | echo "IPv6.value 0" |
| 107 | echo "W: Unable to read /proc/net/snmp6" >&2 |
||
| 108 | e49b78ab | Arturo Borrero Gonzalez | fi |
| 109 | 09b0f002 | Arturo Borrero Gonzalez | echo "total.value $( echo $ipv4 + $ipv6 | bc )" |
| 110 | e49b78ab | Arturo Borrero Gonzalez | |
| 111 | exit 0 |
