Révision 1bed50bb
Update multibandwidth
| plugins/network/multibandwidth | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
|
| 3 |
. "$MUNIN_LIBDIR/plugins/plugin.sh" |
|
| 4 |
|
|
| 3 | 5 |
: <<=cut |
| 4 | 6 |
|
| 5 | 7 |
=head1 NAME |
| ... | ... | |
| 24 | 26 |
user root |
| 25 | 27 |
env.hosts example.org example2.org example3.org |
| 26 | 28 |
env.samples 10 |
| 27 |
env.small_packet_size 1000
|
|
| 28 |
env.big_packet_size 8000
|
|
| 29 |
env.small_packet_size 44
|
|
| 30 |
env.big_packet_size 108
|
|
| 29 | 31 |
|
| 30 | 32 |
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth. |
| 31 | 33 |
|
| ... | ... | |
| 63 | 65 |
case $1 in |
| 64 | 66 |
config) |
| 65 | 67 |
echo graph_title MultiBandwidth |
| 66 |
echo 'graph_vlabel Mbps'
|
|
| 68 |
echo 'graph_vlabel bps' |
|
| 67 | 69 |
echo 'graph_args --base 1024 -l 0' |
| 68 | 70 |
echo 'graph_scale yes' |
| 69 | 71 |
echo 'graph_category network' |
| 70 | 72 |
echo 'graph_info This graph shows the bandwidth between localhost and serveral hosts' |
| 71 | 73 |
for host in $hosts; do |
| 72 |
bandwidth=$((bandwidth+1))
|
|
| 73 |
echo 'bandwidth'"$bandwidth"'.label ' "$host"
|
|
| 74 |
echo 'bandwidth'"$bandwidth"'.draw LINE2'
|
|
| 75 |
echo 'bandwidth'"$bandwidth"'.info Bandwidth statistics for '"$host"
|
|
| 74 |
fieldname="host_$(clean_fieldname "$host")"
|
|
| 75 |
echo "$fieldname.label $host"
|
|
| 76 |
echo "$fieldname.draw LINE2"
|
|
| 77 |
echo "$fieldname.info Bandwidth statistics for $host"
|
|
| 76 | 78 |
done |
| 77 | 79 |
exit 0;; |
| 78 | 80 |
autoconf) |
| ... | ... | |
| 89 | 91 |
|
| 90 | 92 |
#Calculating the bandwidth |
| 91 | 93 |
for host in $hosts; do |
| 92 |
bandwidth=$((bandwidth+1))
|
|
| 93 |
printf "%s""bandwidth""$bandwidth"".value ";
|
|
| 94 |
fieldname="host_$(clean_fieldname "$host")"
|
|
| 95 |
printf "$fieldname.value ";
|
|
| 94 | 96 |
|
| 95 | 97 |
SPEED=$(timeout 6 bing localhost "$host" -n -c 1 -e "$samples" -s "$small_packet_size" -S "$big_packet_size" 2>/dev/null \ |
| 96 | 98 |
|grep "estimated link" -A 2 \ |
| ... | ... | |
| 99 | 101 |
| cut -d "b" -f1) |
| 100 | 102 |
|
| 101 | 103 |
if (echo "$SPEED" | grep -q "M"); then |
| 102 |
echo "$SPEED" | awk '{a+=$1} END{print a}'
|
|
| 104 |
echo "$SPEED" | awk '{a+=$1} END{print a*1000000}'
|
|
| 103 | 105 |
elif (echo "$SPEED" | grep -q "K"); then |
| 104 |
echo "$SPEED" | awk '{a+=$1} END{print a/1000}'
|
|
| 105 |
elif(echo "$SPEED" | grep -q "G"); then |
|
| 106 | 106 |
echo "$SPEED" | awk '{a+=$1} END{print a*1000}'
|
| 107 |
elif (echo "$SPEED" | grep -q "G"); then |
|
| 108 |
echo "$SPEED" | awk '{a+=$1} END{print a*1000000000}'
|
|
| 107 | 109 |
else |
| 108 |
echo "Error: no data"
|
|
| 110 |
echo "Error: no data (timeout)" >&2
|
|
| 109 | 111 |
fi |
| 110 | 112 |
done |
Formats disponibles : Unified diff