Continuous ping monitoring
We have a monitoring system to check network devices, sometimes we got an alert saying the remote device is down. We check the remote device and it’s working fine. To ensure that our monitoring working properly, we create an external script to monitor system, then we want to compare the result between 2 systems. I finally come with this script (ping.sh) , it will continuously ping the remote server, if it’s down, it will write a log.
if [[ -n $1 ]]
fping -c3 $hostname ;
if [[ $? -ne 0 ]]
echo "============System [$hostname] is down============"
echo "$d System [$hostname] is down " >>log.txt
traceroute $hostname >>log.txt 2>&1
I want to run this script in background so i run it like this:
nohup ./ping.sh www.myserver.com &
The script is just the basic only, you can do a lot of customization such as format the log.