mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Update multibandwidth
This commit is contained in:
parent
f679a922d5
commit
1bed50bb64
1 changed files with 15 additions and 13 deletions
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||||
|
|
||||||
: <<=cut
|
: <<=cut
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
@ -24,8 +26,8 @@ The following is the default configuration
|
||||||
user root
|
user root
|
||||||
env.hosts example.org example2.org example3.org
|
env.hosts example.org example2.org example3.org
|
||||||
env.samples 10
|
env.samples 10
|
||||||
env.small_packet_size 1000
|
env.small_packet_size 44
|
||||||
env.big_packet_size 8000
|
env.big_packet_size 108
|
||||||
|
|
||||||
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth.
|
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth.
|
||||||
|
|
||||||
|
@ -63,16 +65,16 @@ GPLv2
|
||||||
case $1 in
|
case $1 in
|
||||||
config)
|
config)
|
||||||
echo graph_title MultiBandwidth
|
echo graph_title MultiBandwidth
|
||||||
echo 'graph_vlabel Mbps'
|
echo 'graph_vlabel bps'
|
||||||
echo 'graph_args --base 1024 -l 0'
|
echo 'graph_args --base 1024 -l 0'
|
||||||
echo 'graph_scale yes'
|
echo 'graph_scale yes'
|
||||||
echo 'graph_category network'
|
echo 'graph_category network'
|
||||||
echo 'graph_info This graph shows the bandwidth between localhost and serveral hosts'
|
echo 'graph_info This graph shows the bandwidth between localhost and serveral hosts'
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
bandwidth=$((bandwidth+1))
|
fieldname="host_$(clean_fieldname "$host")"
|
||||||
echo 'bandwidth'"$bandwidth"'.label ' "$host"
|
echo "$fieldname.label $host"
|
||||||
echo 'bandwidth'"$bandwidth"'.draw LINE2'
|
echo "$fieldname.draw LINE2"
|
||||||
echo 'bandwidth'"$bandwidth"'.info Bandwidth statistics for '"$host"
|
echo "$fieldname.info Bandwidth statistics for $host"
|
||||||
done
|
done
|
||||||
exit 0;;
|
exit 0;;
|
||||||
autoconf)
|
autoconf)
|
||||||
|
@ -89,8 +91,8 @@ esac
|
||||||
|
|
||||||
#Calculating the bandwidth
|
#Calculating the bandwidth
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
bandwidth=$((bandwidth+1))
|
fieldname="host_$(clean_fieldname "$host")"
|
||||||
printf "%s""bandwidth""$bandwidth"".value ";
|
printf "$fieldname.value ";
|
||||||
|
|
||||||
SPEED=$(timeout 6 bing localhost "$host" -n -c 1 -e "$samples" -s "$small_packet_size" -S "$big_packet_size" 2>/dev/null \
|
SPEED=$(timeout 6 bing localhost "$host" -n -c 1 -e "$samples" -s "$small_packet_size" -S "$big_packet_size" 2>/dev/null \
|
||||||
|grep "estimated link" -A 2 \
|
|grep "estimated link" -A 2 \
|
||||||
|
@ -99,12 +101,12 @@ for host in $hosts; do
|
||||||
| cut -d "b" -f1)
|
| cut -d "b" -f1)
|
||||||
|
|
||||||
if (echo "$SPEED" | grep -q "M"); then
|
if (echo "$SPEED" | grep -q "M"); then
|
||||||
echo "$SPEED" | awk '{a+=$1} END{print a}'
|
echo "$SPEED" | awk '{a+=$1} END{print a*1000000}'
|
||||||
elif (echo "$SPEED" | grep -q "K"); then
|
elif (echo "$SPEED" | grep -q "K"); then
|
||||||
echo "$SPEED" | awk '{a+=$1} END{print a/1000}'
|
|
||||||
elif(echo "$SPEED" | grep -q "G"); then
|
|
||||||
echo "$SPEED" | awk '{a+=$1} END{print a*1000}'
|
echo "$SPEED" | awk '{a+=$1} END{print a*1000}'
|
||||||
|
elif (echo "$SPEED" | grep -q "G"); then
|
||||||
|
echo "$SPEED" | awk '{a+=$1} END{print a*1000000000}'
|
||||||
else
|
else
|
||||||
echo "Error: no data"
|
echo "Error: no data (timeout)" >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue