From 1bed50bb642894252960f0f44bad7083488b6b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Manuel=20Febrer=20Cort=C3=A9s?= Date: Thu, 23 Mar 2017 11:15:32 +0100 Subject: [PATCH] Update multibandwidth --- plugins/network/multibandwidth | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/network/multibandwidth b/plugins/network/multibandwidth index 70c3433a..4f4f7298 100644 --- a/plugins/network/multibandwidth +++ b/plugins/network/multibandwidth @@ -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