Projet

Général

Profil

Révision a1cc26f2

IDa1cc26f2d3c0baeb52d13e14823951f14ca63afc
Parent 651f6ac0
Enfant 1ae4ac09

Ajouté par Jose Manuel Febrer Cortés il y a plus de 7 ans

Update multibandwidth

bing have some random spikes. Added a variable that is used to indicate the maximum value of mbps that can be recorded (in bps).

Voir les différences:

plugins/network/multibandwidth
1
#!/bin/sh
2

  
3
. "$MUNIN_LIBDIR/plugins/plugin.sh"
4

  
5
: <<=cut
6

  
7
=head1 NAME
8

  
9
multibandwidth - Plugin to monitor the bandwidth between localhost and serveral hosts.
10

  
11
=head1 APPLICABLE SYSTEMS
12

  
13
All systems with “bash”, and “munin”
14

  
15
=head1 REQUIREMENTS
16

  
17
bing installed.
18

  
19
You can install bing by using (Ubuntu/Debian): apt-get install bing
20

  
21
=head1 CONFIGURATION
22

  
23
The following is the default configuration
24

  
25
[multibandwidth]
26
user root
27
env.hosts example.org example2.org example3.org
28
env.samples 10
29
env.small_packet_size 44
30
env.big_packet_size 108
31

  
32
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth.
33

  
34
- env.samples explanation: Reset stats after sending samples ECHO_REQUEST packets.
1
#!/bin/sh                                                                                                                                                                                                         
2
                                                                                                                                                                                                                  
3
. "$MUNIN_LIBDIR/plugins/plugin.sh"                                                                                                                                                                               
4
                                                                                                                                                                                                                  
5
: <<=cut                                                                                                                                                                                                          
6
                                                                                                                                                                                                                  
7
=head1 NAME                                                                                                                                                                                                       
8
                                                                                                                                                                                                                  
9
multibandwidth - Plugin to monitor the bandwidth between localhost and serveral hosts.                                                                                                                            
10
                                                                                                                                                                                                                  
11
=head1 APPLICABLE SYSTEMS                                                                                                                                                                                         
12
                                                                                                                                                                                                                  
13
All systems with “bash”, and “munin”                                                                                                                                                                              
14
                                                                                                                                                                                                                  
15
=head1 REQUIREMENTS                                                                                                                                                                                               
16
                                                                                                                                                                                                                  
17
bing installed.                                                                                                                                                                                                   
18
                                                                                                                                                                                                                  
19
You can install bing by using (Ubuntu/Debian): apt-get install bing                                                                                                                                               
20
                                                                                                                                                                                                                  
21
=head1 CONFIGURATION                                                                                                                                                                                              
22
                                                                                                                                                                                                                  
23
The following is the default configuration                                                                                                                                                                        
24
                                                                                                                                                                                                                  
25
[multibandwidth]                                                                                                                                                                                                  
26
user root                                                                                                                                                                                                         
27
env.hosts example.org example2.org example3.org                                                                                                                                                                   
28
env.samples 15                                                                                                                                                                                                    
29
env.small_packet_size 44                                                                                                                                                                                          
30
env.big_packet_size 108                                                                                                                                                                                           
31
env.max_mbps 15728640                                                                                                                                                                                             
32
                                                                                                                                                                                                                  
33
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth.                                                                                                                                  
34
                                                                                                                                                                                                                  
35
- env.samples explanation: Reset stats after sending samples ECHO_REQUEST packets.                                                                                                                                
35 36

  
36 37
- env.small_packet_size explanation: Specifies the number of data bytes to be sent in the small
37 38
        packets. The default and minimum value is 44.
......
40 41
        packets. The default is 108. The size should be chosen so that big packet roundtrip times
41 42
        are long enough to be accurately measured.
42 43

  
44
- env.max_mbps explanation: bing have some random spikes. This variable is used to indicate
45
        the maximum value of mbps that can be recorded (in bps).
43 46

  
44 47
=head1 MAGIC MARKERS
45 48

  
......
101 104
                | cut -d "b" -f1)
102 105

  
103 106
        if (echo "$SPEED" | grep -q "M"); then
104
                echo "$SPEED" | awk '{a+=$1} END{print a*1000000}'
107
                VALUE=`echo "$SPEED" | sed 's/.$//'`
108
                RATE=`echo "$VALUE * 1048576" | bc -l`
109

  
110
                if [ $(echo "$RATE" >= "$max_mbps" | bc >/dev/null && echo "no" || echo "yes") = "yes" ]; then
111
                        echo "$max_mbps"
112
                else
113
                        echo "$RATE"
114
                fi
105 115
        elif (echo "$SPEED" | grep -q "K"); then
106
                echo "$SPEED" | awk '{a+=$1} END{print a*1000}'
116
                VALUE=`echo "$SPEED" | sed 's/.$//'`
117
                echo "$VALUE * 1024" | bc -l
107 118
        elif (echo "$SPEED" | grep -q "G"); then
108
                echo "$SPEED" | awk '{a+=$1} END{print a*1000000000}'
119
                VALUE=`echo "$SPEED" | sed 's/.$//'`
120
                echo "$VALUE * 1073742000" | bc -l
109 121
        else
110 122
                echo "Error: no data (timeout)" >&2
111 123
        fi

Formats disponibles : Unified diff