Monday, April 4, 2011

Traceroute shell script for linux/unix

Before you run the below script you need to save server list in /tmp/servlist. The below mentioned bash script you need to put in crontab to run as per the schedule. This script will send the traceroute whenever node/server is down. Please comment if this script is useful for you.

#Author : Ranjith Kumar R
#Purpose : To send the traceroute whenever server/node is down.
#Version : V1.0
#Date :April 05, 2011

Trace="/bin/traceroute -I"

for i in `cat /tmp/servlist`
test=`fping $i | grep unreachable | awk '{print $1'}`
echo $test
if [ -z "$test" ]; then
sleep 1
$Trace $test | mail -s "$test is Down!!! Traceroute from $Hostname to $test" &


No comments:

Post a Comment