2
0
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:
Jose Manuel Febrer Cortés 2017-03-23 11:15:32 +01:00 committed by GitHub
parent f679a922d5
commit 1bed50bb64

View File

@ -1,5 +1,7 @@
#!/bin/sh
. "$MUNIN_LIBDIR/plugins/plugin.sh"
: <<=cut
=head1 NAME
@ -24,8 +26,8 @@ The following is the default configuration
user root
env.hosts example.org example2.org example3.org
env.samples 10
env.small_packet_size 1000
env.big_packet_size 8000
env.small_packet_size 44
env.big_packet_size 108
- env.hosts explanation: hostname or IP of the hosts to calculate the bandwidth.
@ -63,16 +65,16 @@ GPLv2
case $1 in
config)
echo graph_title MultiBandwidth
echo 'graph_vlabel Mbps'
echo 'graph_vlabel bps'
echo 'graph_args --base 1024 -l 0'
echo 'graph_scale yes'
echo 'graph_category network'
echo 'graph_info This graph shows the bandwidth between localhost and serveral hosts'
for host in $hosts; do
bandwidth=$((bandwidth+1))
echo 'bandwidth'"$bandwidth"'.label ' "$host"
echo 'bandwidth'"$bandwidth"'.draw LINE2'
echo 'bandwidth'"$bandwidth"'.info Bandwidth statistics for '"$host"
fieldname="host_$(clean_fieldname "$host")"
echo "$fieldname.label $host"
echo "$fieldname.draw LINE2"
echo "$fieldname.info Bandwidth statistics for $host"
done
exit 0;;
autoconf)
@ -89,8 +91,8 @@ esac
#Calculating the bandwidth
for host in $hosts; do
bandwidth=$((bandwidth+1))
printf "%s""bandwidth""$bandwidth"".value ";
fieldname="host_$(clean_fieldname "$host")"
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 \
|grep "estimated link" -A 2 \
@ -99,12 +101,12 @@ for host in $hosts; do
| cut -d "b" -f1)
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
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}'
elif (echo "$SPEED" | grep -q "G"); then
echo "$SPEED" | awk '{a+=$1} END{print a*1000000000}'
else
echo "Error: no data"
echo "Error: no data (timeout)" >&2
fi
done