tracert

auto_tracert.sh

#!/bin/bash
#mwg@1013-1-30
for i in $@
do
setsid ./tracert.sh $i &
done


tracert.sh

#!/bin/sh
#mwg@1013-1-30
#eg setsid ./tracert.sh 219.239.93.157&
###################
[ -d $1 ] || mkdir $1
tmp_log=./$1/$1'_pingtmp.log'
ping_log=./$1/$1'_24ping.log'
tracert_log=./$1/$1'_tracert.log'
###################
while :
do
time=`date +%Y-%m-%d\|%T`
ping -c 1 $1 |awk '/ttl=/'|sed "s/^/${time} /" 1> $tmp_log
grep from $tmp_log > /dev/null;
a=$?
if [ $a -ne 0 ] ; then
echo ${time} timeout >> $ping_log
echo ================${time}================= >> $tracert_log
tracert -d $1 >> $tracert_log
else
cat pingtmp.txt >> $ping_log
fi
[ -f $tmp_log ] && rm -f $tmp_log
sleep 1;
done


你可能感兴趣的:(tracert)