Thursday, June 28, 2007

Tech: Keeping your DSL Provider Honest...

So you've got an always on Internet connection? Throw in a static IP address or two, and you're probably already paying too much per month for your oversubscribed DSL. Add in the occasional DSL downtime, and like me, you can get pretty frustrated. If you have an SLA for uptime baked in to your DSL contract, then, as Jim Cramer would put it, "time to back the truck up". Now all you need is evidence right? Here is a bash shell I wrote to do just that. You can either run it from your home network using outbound pings, or run it how I am using inbound pings. In your haste, don't forget to make sure you haven't flubbed something up before you go ranting about service credits. Now go out and make your DSL provider honest!


#!/bin/bash

# Name: pinger
# Usage: nohup ./pinger &
# Output: $HOME/dslDown.txt and email Notifications
# Changes required prior to use: emailTo, testIP


emailTo=you@domain.com;
testIP=10.10.10.220;
counter=0;
minutes=0;
startDate=`date`;
if [ -f $HOME/dslDown.txt ]; then
mv $HOME/dslDown.txt $HOME/dslDown$$.txt;
fi
echo "Ping tests to $testIP initiated on $startDate" >> $HOME/dslDown.txt;

while (true); do
ping -W 5 -c 1 $testIP > /dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Unreachable at `date`" >> $HOME/dslDown.txt
counter=$[counter+=1]
if (($counter==10)); then
minutes=$[minutes+5];
counter=0;
echo "DSL down for a total of $minutes minutes between $startDate and `date`." >> $HOME/dslDown.txt
mailx -s "DSL down for a total of $minutes minutes between $startDate and `date`." $emailTo < $HOME/dslDown.txt;
fi
fi
sleep 30
done