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:

## ##
## This script continually pings an IP address / hostname and reports *only*
## when it is unable to reach the destination.
## Example: ./

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

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

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

./ [my neighboring workstation]
./ [my gateway]
./ [my ISPs DNS]
./ [random domain - ie. or]

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

No comments:

Post a Comment