2012-04-17 19:49:48 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Plugin plotting the Percentage of time needed to reach each host on the way to a certain host
|
|
|
|
# Uses MTR http://www.bitwizard.nl/mtr/ to do the job
|
|
|
|
#
|
|
|
|
# Version: 1.0
|
|
|
|
# Author: tobias.geiger@vido.info
|
2016-02-06 05:03:21 +01:00
|
|
|
# Please email me bugs/suggestions
|
2012-04-17 19:49:48 +02:00
|
|
|
#
|
2012-04-17 23:47:02 +02:00
|
|
|
# Version: 1.1
|
|
|
|
# Author: charlie@evilforbeginners.com
|
|
|
|
# changed: munin eats 1 character ds-names. prefix with "hop_"
|
2012-04-17 19:49:48 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# HINT: Needs a bigger TIMEOUT-Value than the default (10) in /etc/munin/plugin-conf.d/munin-node ,
|
|
|
|
# e.g.:
|
|
|
|
# [mtr100_*]
|
|
|
|
# timeout 60
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Parameters:
|
|
|
|
#
|
2016-11-12 20:29:05 +01:00
|
|
|
# config (required)
|
|
|
|
# autoconf (optional - only used by munin-config)
|
2012-04-17 19:49:48 +02:00
|
|
|
#
|
|
|
|
# Magic markers (optional - used by munin-config and some installation
|
|
|
|
# scripts):
|
|
|
|
#%# family=contrib
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
totrace=`basename $0 | sed 's/^mtr100_//g'`
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2016-11-12 20:29:05 +01:00
|
|
|
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
|
2012-04-17 19:49:48 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
dotrace() {
|
|
|
|
|
2016-11-12 19:48:09 +01:00
|
|
|
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) ' {
|
2012-04-17 19:49:48 +02:00
|
|
|
|
|
|
|
label=$2
|
|
|
|
x=gsub("\\.","_",label)
|
|
|
|
|
|
|
|
count=NR
|
|
|
|
lab[count]=count
|
|
|
|
name[count]=$2
|
|
|
|
val[count]=$6
|
|
|
|
total+=$6
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
2016-11-12 21:20:24 +01:00
|
|
|
# Hard code the first hop (hop_0) as the local hostname
|
2016-11-12 20:29:05 +01:00
|
|
|
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" }
|
|
|
|
}
|
2012-04-17 19:49:48 +02:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
2016-11-12 20:29:05 +01:00
|
|
|
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
|
2012-04-17 19:49:48 +02:00
|
|
|
else
|
2016-11-12 20:29:05 +01:00
|
|
|
dotrace;
|
2012-04-17 19:49:48 +02:00
|
|
|
fi
|