Projet

Général

Profil

Révision e49b78ab

IDe49b78ab528a3f2de0d2f0fd58c32c2b03ae806e
Parent 73bf794a
Enfant 0a0cc634

Ajouté par Arturo Borrero Gonzalez il y a environ 13 ans

Added `traffic' plugin, to allow measure server total throughput in both IPv4 and IPv6

Voir les différences:

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