traceroute-monitor.sh script
Sample script
This script is available at $PATROL_HOME\..\TRO\Conf\Scripts\Samples directory. The script content is as follows:
#!/bin/bash -f
# this sample script can be used with the KM to set-up monitoring to network traceability, using
# command line tool 'traceroute'.
# using this script the KM measures the TTL of packages from given device to all the network components
# on the path to another device. Device A --> Device B.
# when used with a policy the configured device A is connected and executing the script, while Device B is provided as an argument for the script.
# the script also demonstrates:
# 1. bc used to calculate average values and
# 2. printf used to add leading '0' on single digit numbers
# 3. tr is used to remove 1 or more SPACE characters
#==================================================================================================
# NOTICE: the script is compatible with BASH and KSH, but not plain SH, since it's using functions.
#==================================================================================================
function process_host
{
case $# in
4 )
#(>&2 echo "No data received: * * *")
;;
9 )
RT_MSGAVG=`echo "scale=2;($4 + $6 + $8)/3" | bc`
HOP_NUM=`printf "%02d" $1`
echo RoutingHost=\($HOP_NUM\):$2,1stMsgResponseTime=$4,2ndMsgResponseTime=$6,3rdMsgResponseTime=$8,AvgResponseTime=$RT_MSGAVG
;;
10 )
#(>&2 echo "Trace route to $2 $3")
;;
* )
#(>&2 echo "Unknown device data")
;;
esac
}
for line in $(traceroute $1|sed 's/ /+/g')
do
CLEAN_LINE=`echo $line | tr '+' ' '`
process_host $CLEAN_LINE
done
# this sample script can be used with the KM to set-up monitoring to network traceability, using
# command line tool 'traceroute'.
# using this script the KM measures the TTL of packages from given device to all the network components
# on the path to another device. Device A --> Device B.
# when used with a policy the configured device A is connected and executing the script, while Device B is provided as an argument for the script.
# the script also demonstrates:
# 1. bc used to calculate average values and
# 2. printf used to add leading '0' on single digit numbers
# 3. tr is used to remove 1 or more SPACE characters
#==================================================================================================
# NOTICE: the script is compatible with BASH and KSH, but not plain SH, since it's using functions.
#==================================================================================================
function process_host
{
case $# in
4 )
#(>&2 echo "No data received: * * *")
;;
9 )
RT_MSGAVG=`echo "scale=2;($4 + $6 + $8)/3" | bc`
HOP_NUM=`printf "%02d" $1`
echo RoutingHost=\($HOP_NUM\):$2,1stMsgResponseTime=$4,2ndMsgResponseTime=$6,3rdMsgResponseTime=$8,AvgResponseTime=$RT_MSGAVG
;;
10 )
#(>&2 echo "Trace route to $2 $3")
;;
* )
#(>&2 echo "Unknown device data")
;;
esac
}
for line in $(traceroute $1|sed 's/ /+/g')
do
CLEAN_LINE=`echo $line | tr '+' ' '`
process_host $CLEAN_LINE
done
Example
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*