From dc129c541b1c2c6bf5be0368bec706b5403c1ba0 Mon Sep 17 00:00:00 2001 From: Lee Clemens Date: Fri, 5 Feb 2016 23:03:21 -0500 Subject: [PATCH 1/4] Add source HOST to graph_title --- plugins/network/mtr100_ | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/network/mtr100_ b/plugins/network/mtr100_ index 2e439519..ec07888d 100755 --- a/plugins/network/mtr100_ +++ b/plugins/network/mtr100_ @@ -5,7 +5,7 @@ # # Version: 1.0 # Author: tobias.geiger@vido.info -# Please email me bugs/suggestions +# Please email me bugs/suggestions # # Version: 1.1 # Author: charlie@evilforbeginners.com @@ -63,7 +63,7 @@ total+=$6 } END { - for (x=1; x<=count; x++) { + for (x=1; x<=count; x++) { value=(val[x]/total)*100 if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value } if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] } @@ -73,8 +73,7 @@ END { } if [ "$1" = "config" ]; then - - echo 'graph_title Traceroute (%) to '$totrace + echo "graph_title Traceroute `mtr -nrc 1 localhost | grep -E '^HOST' | awk '{print $2}'` to "$totrace echo 'graph_args --base 1000 -l 0 -u 100 -r' echo 'graph_vlabel ms (percentage)' echo 'graph_category network' @@ -86,4 +85,3 @@ if [ "$1" = "config" ]; then else dotrace; fi - From b3a486fa624118686b9eda5a42a2241409c5792c Mon Sep 17 00:00:00 2001 From: Lee Clemens Date: Sat, 12 Nov 2016 13:48:09 -0500 Subject: [PATCH 2/4] Use source hostname as first 'hop' value (removing it from graph title) --- plugins/network/mtr100_ | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/network/mtr100_ b/plugins/network/mtr100_ index ec07888d..f726c55a 100755 --- a/plugins/network/mtr100_ +++ b/plugins/network/mtr100_ @@ -50,7 +50,7 @@ fi dotrace() { -LC_ALL=C mtr -nrs 1024 -c 5 $totrace | grep -vi -E "^HOST:|^Start:" | LC_ALL=C awk -v C=$1 ' { +LC_ALL=C mtr -nrs 1024 -c 5 $totrace | grep -vi -E "^HOST:|^Start:" | LC_ALL=C awk -v C=$1 -v SRC_HOSTNAME=$(hostname) ' { label=$2 x=gsub("\\.","_",label) @@ -63,17 +63,20 @@ total+=$6 } END { + if ( C != "config" ) { print "hop_0.value U" } + if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME } + if ( C == "config" ) { print "hop_0.draw AREA" } for (x=1; x<=count; x++) { value=(val[x]/total)*100 if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value } if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] } - if ( C == "config" ) { if ( x == 1 ) { print "hop_" lab[x]".draw AREA" } else { print "hop_" lab[x]".draw STACK" } } + if ( C == "config" ) { print "hop_" lab[x]".draw STACK" } } }' } if [ "$1" = "config" ]; then - echo "graph_title Traceroute `mtr -nrc 1 localhost | grep -E '^HOST' | awk '{print $2}'` to "$totrace + echo 'graph_title Traceroute (%) to '$totrace echo 'graph_args --base 1000 -l 0 -u 100 -r' echo 'graph_vlabel ms (percentage)' echo 'graph_category network' From d9cce2160f0dbfad72a29222ccc9363b1b271a81 Mon Sep 17 00:00:00 2001 From: Lee Clemens Date: Sat, 12 Nov 2016 14:29:05 -0500 Subject: [PATCH 3/4] Make whitespace consistent, converting tabs to 4 spaces and fixing indents --- plugins/network/mtr100_ | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/plugins/network/mtr100_ b/plugins/network/mtr100_ index f726c55a..18ddf28e 100755 --- a/plugins/network/mtr100_ +++ b/plugins/network/mtr100_ @@ -21,8 +21,8 @@ # # Parameters: # -# config (required) -# autoconf (optional - only used by munin-config) +# config (required) +# autoconf (optional - only used by munin-config) # # Magic markers (optional - used by munin-config and some installation # scripts): @@ -32,19 +32,19 @@ totrace=`basename $0 | sed 's/^mtr100_//g'` if [ "$1" = "autoconf" ]; then - if ( mtr -nrc 1 localhost 2>/dev/null >/dev/null ); then - echo yes - exit 0 - else - if [ $? -eq 127 ] - then - echo "no (mtr program not found - install the mtr(-tiny) package)" - exit 1 - else - echo no - exit 1 - fi - fi + if ( mtr -nrc 1 localhost 2>/dev/null >/dev/null ); then + echo yes + exit 0 + else + if [ $? -eq 127 ] + then + echo "no (mtr program not found - install the mtr(-tiny) package)" + exit 1 + else + echo no + exit 1 + fi + fi exit 0 fi @@ -63,28 +63,28 @@ total+=$6 } END { - if ( C != "config" ) { print "hop_0.value U" } - if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME } - if ( C == "config" ) { print "hop_0.draw AREA" } - for (x=1; x<=count; x++) { - value=(val[x]/total)*100 - if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value } - if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] } - if ( C == "config" ) { print "hop_" lab[x]".draw STACK" } - } + if ( C != "config" ) { print "hop_0.value U" } + if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME } + if ( C == "config" ) { print "hop_0.draw AREA" } + for (x=1; x<=count; x++) { + value=(val[x]/total)*100 + if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value } + if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] } + if ( C == "config" ) { print "hop_" lab[x]".draw STACK" } + } }' } if [ "$1" = "config" ]; then - echo 'graph_title Traceroute (%) to '$totrace - echo 'graph_args --base 1000 -l 0 -u 100 -r' - echo 'graph_vlabel ms (percentage)' - echo 'graph_category network' - echo 'graph_scale no' - echo 'graph_period second' - echo 'graph_info This graph shows the Percentage needed for each hop on the way to '$totrace - dotrace config; - exit 0 + echo 'graph_title Traceroute (%) to '$totrace + echo 'graph_args --base 1000 -l 0 -u 100 -r' + echo 'graph_vlabel ms (percentage)' + echo 'graph_category network' + echo 'graph_scale no' + echo 'graph_period second' + echo 'graph_info This graph shows the Percentage needed for each hop on the way to '$totrace + dotrace config; + exit 0 else - dotrace; + dotrace; fi From caa2f4be1824179967029dc96048c85a1c142390 Mon Sep 17 00:00:00 2001 From: Lee Clemens Date: Sat, 12 Nov 2016 15:20:24 -0500 Subject: [PATCH 4/4] Add comment for hardcoded hop_o value and configs --- plugins/network/mtr100_ | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/network/mtr100_ b/plugins/network/mtr100_ index 18ddf28e..44ed34f3 100755 --- a/plugins/network/mtr100_ +++ b/plugins/network/mtr100_ @@ -63,6 +63,7 @@ total+=$6 } END { + # Hard code the first hop (hop_0) as the local hostname if ( C != "config" ) { print "hop_0.value U" } if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME } if ( C == "config" ) { print "hop_0.draw AREA" }