Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkingorg/a51679cf6a450d455418 to your computer and use it in GitHub Desktop.
Save alexkingorg/a51679cf6a450d455418 to your computer and use it in GitHub Desktop.
Script to check the uptime of my ISP - I run this from a CRON job on a local box.
#!/bin/bash
# try 3 times - sometimes getting an initial DNS failure that clears up
COUNTER=0
while [ $COUNTER -lt 3 ]; do
ping -c 1 google.com &> /dev/null
if [ $? -ne 0 ]; then
echo "`date`: ping failed, isp is down!" >> /Users/aking/Dropbox/Temp/isp-ping-result.log
echo "`date`: ping failed, isp is down!" >> /Users/aking/Dropbox/Temp/isp-downtime.log
else
echo "`date`: ping succeeded." >> /Users/aking/Dropbox/Temp/isp-ping-result.log
let COUNTER=3
fi
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment