Monday, September 17, 2007

Simple network uptime test

Trying to troubleshoot an intermittent network problem? Just want to know if you ISP is dropping packets or going down altogether?

So many times I've search the 'net for a simple network uptime script. I always wanted to know the exact time the network went down (and came back up) so that I could track down the cause of the problem. Here is a dead-simple script that will do just that:

#!/bin/bash
## connect_test.sh ##
## This script continually pings an IP address / hostname and reports *only*
## when it is unable to reach the destination.
##
## Example: ./connect_test.sh www.google.com

if [[ $1 == "" ]];
then
echo "Please provide an IP/host to ping"
exit
fi

while [ true ]; do
p=`ping -c 4 $1 > /dev/null 2>&1`
if [[ $? != 0 ]];
then
d=`date`
echo "Unable to reach $1 at $d"
sleep 1
fi
done

It works best if you open up multiple terminal windows and try to connect to different portions of your network simultaneously. For example:

./connect_test.sh [my neighboring workstation]
./connect_test.sh [my gateway]
./connect_test.sh [my ISPs DNS]
./connect_test.sh [random domain - ie. google.com or yahoo.com]

This way, you can determine exactly where the failure is AND you have a record of the time it occurred. Hope that helps!

1 comment:

  1. If you’re touring in considered one of these nations and you’re having bother accessing the service, you can use use|you need to use} a VPN to switch your location to your own home} country. IPVanish boasts excellent safety, utilizing 256-bit encryption and ideal forward secrecy to keep your connection secure. A built-in kill swap adds 벳익스플로어 an additional layer of protection by stopping all knowledge switch should the VPN connection drop. It supplies DNS leak protection and doesn’t monitor any searching activity or maintain connection logs. In case of questions or issues, you could have} entry to 24/7 stay chat help. IPVanish Fast and reliable service with good secure servers and apps.

    ReplyDelete