2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Plugin multibandwidth: simplify speed calculation

This commit is contained in:
Lars Kruse 2018-07-11 20:25:57 +02:00
parent 1ae4ac09da
commit 49aecf4e0e

View File

@ -95,7 +95,6 @@ esac
#Calculating the bandwidth #Calculating the bandwidth
for host in $hosts; do for host in $hosts; do
fieldname="host_$(clean_fieldname "$host")" 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 \ 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 \
@ -103,22 +102,17 @@ for host in $hosts; do
| awk '{print $2}' \ | awk '{print $2}' \
| cut -d "b" -f1) | cut -d "b" -f1)
if (echo "$SPEED" | grep -q "M"); then if echo "$SPEED" | grep -q "M"; then
VALUE=`echo "$SPEED" | sed 's/.$//'` RATE=$(echo "$SPEED" | awk '{ print int($1 * 1024 * 1024); }')
RATE=`echo "$VALUE * 1048576" | bc -l` elif echo "$SPEED" | grep -q "K"; then
RATE=$(echo "$SPEED" | awk '{ print int($1 * 1024); }')
if [ `echo "$RATE > $max_mbps" | bc` -eq "1" ]; then elif echo "$SPEED" | grep -q "G"; then
echo "$max_mbps" RATE=$(echo "$SPEED" | awk '{ print int($1 * 1024 * 1024 * 1024); }')
else
echo "$RATE"
fi
elif (echo "$SPEED" | grep -q "K"); then
VALUE=`echo "$SPEED" | sed 's/.$//'`
echo "$VALUE * 1024" | bc -l
elif (echo "$SPEED" | grep -q "G"); then
VALUE=`echo "$SPEED" | sed 's/.$//'`
echo "$VALUE * 1073742000" | bc -l
else else
echo "Error: no data (timeout)" >&2 echo "Error: no data (timeout)" >&2
fi fi
if [ "$RATE" -gt "$max_mbps" ]; then
RATE="$max_mbps"
fi
echo "${fieldname}.value $RATE"
done done