Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / traffic @ f2032538

Historique | Voir | Annoter | Télécharger (1,37 ko)

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
total.label Total bps
55
total.min 0
56
total.type DERIVE
57
total.draw LINE1
58
EOF
59
        exit 0
60
fi
61

    
62

    
63
if [ -r /proc/net/dev ]
64
then
65
	ipv4=$( echo "`egrep -v bond\|lo /proc/net/dev | awk -F' ' '{print $2+$10}' | paste -sd+ | bc` * 8" | bc )
66
	echo "IPv4.value $ipv4"
67
else
68
	echo "IPv4.value 0"
69
	echo "W: Unable to read /proc/net/dev" >&2
70
fi
71

    
72
if [ -r /proc/net/snmp6 ]
73
then
74
	ipv6=$( echo "`egrep Ip6InOctets\|Ip6OutOctets /proc/net/snmp6 | awk -F' ' '{print $2}' | paste -sd+ | bc` * 8"  | bc )
75
	echo "IPv6.value $ipv6"
76
else
77
	echo "IPv6.value 0"
78
	echo "W: Unable to read /proc/net/snmp6" >&2
79
fi
80
echo "total.value $( echo $ipv4 + $ipv6 | bc )"
81

    
82
exit 0
83