I am trying to make a script to run constantly that produces a log showing ping stats. I want the log to contain and ping fails, times over 500ms and the traceroute of any timeouts. Here my script:
#!/bin/bash
ip=www.google.com
while [ 1 ]; do
ping -c 1 $ip 1> /dev/null
result=$?
if [ $result == "1" ]; then
echo FAIL on `date` >> ~/ping.log
echo FAIL on `date`. Doing tracert!
traceroute $ip >> ~/ping.log
fi
if [ $result == "0" ]; then
echo SUCCEED on `date` >> ~/ping.log
echo SUCCEED on `date`
fi
sleep .4
done
I copied this script from another site.