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

Merge pull request #771 from leeclemens/mtr_title

Add source as first 'hop' (Closes: #692)
This commit is contained in:
sumpfralle 2016-11-12 21:38:45 +01:00 committed by GitHub
commit c9123a872b

View File

@ -21,8 +21,8 @@
# #
# Parameters: # Parameters:
# #
# config (required) # config (required)
# autoconf (optional - only used by munin-config) # autoconf (optional - only used by munin-config)
# #
# Magic markers (optional - used by munin-config and some installation # Magic markers (optional - used by munin-config and some installation
# scripts): # scripts):
@ -32,25 +32,25 @@
totrace=`basename $0 | sed 's/^mtr100_//g'` totrace=`basename $0 | sed 's/^mtr100_//g'`
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if ( mtr -nrc 1 localhost 2>/dev/null >/dev/null ); then if ( mtr -nrc 1 localhost 2>/dev/null >/dev/null ); then
echo yes echo yes
exit 0 exit 0
else else
if [ $? -eq 127 ] if [ $? -eq 127 ]
then then
echo "no (mtr program not found - install the mtr(-tiny) package)" echo "no (mtr program not found - install the mtr(-tiny) package)"
exit 1 exit 1
else else
echo no echo no
exit 1 exit 1
fi fi
fi fi
exit 0 exit 0
fi fi
dotrace() { 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 label=$2
x=gsub("\\.","_",label) x=gsub("\\.","_",label)
@ -63,27 +63,29 @@ total+=$6
} }
END { END {
for (x=1; x<=count; x++) { # Hard code the first hop (hop_0) as the local hostname
value=(val[x]/total)*100 if ( C != "config" ) { print "hop_0.value U" }
if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value } if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME }
if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] } if ( C == "config" ) { print "hop_0.draw AREA" }
if ( C == "config" ) { if ( x == 1 ) { print "hop_" lab[x]".draw AREA" } else { print "hop_" lab[x]".draw STACK" } } 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 if [ "$1" = "config" ]; then
echo 'graph_title Traceroute (%) to '$totrace
echo 'graph_title Traceroute (%) to '$totrace echo 'graph_args --base 1000 -l 0 -u 100 -r'
echo 'graph_args --base 1000 -l 0 -u 100 -r' echo 'graph_vlabel ms (percentage)'
echo 'graph_vlabel ms (percentage)' echo 'graph_category network'
echo 'graph_category network' echo 'graph_scale no'
echo 'graph_scale no' echo 'graph_period second'
echo 'graph_period second' echo 'graph_info This graph shows the Percentage needed for each hop on the way to '$totrace
echo 'graph_info This graph shows the Percentage needed for each hop on the way to '$totrace dotrace config;
dotrace config; exit 0
exit 0
else else
dotrace; dotrace;
fi fi