Last active
August 29, 2015 14:20
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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