When I cannot reach one of my sites, I do not know if it is my problem, my ISP’s or my hosting provider’s. This is why I use the service down for everyone or just me.
I have written a simple script which uses that service. Its usage is:
$ ./is_up.sh commandliners.com
commandliners.com is up
and the script is:
#!/bin/bash
# is_up.sh
# 2009 - Rafa Casado - rafacas@commandliners.com
numargs=$#
if [ $numargs -ne 1 ]
then
echo "Usage: $0 domain"
echo "Ex: $0 commandliners.com"
exit 1
fi
DOMAIN=$1
IS_UP=`wget -nv -O - "http://downforeveryoneorjustme.com/$DOMAIN" 2>&1 | \
grep "is up"`
if [ $? == "1" ]; then
echo "$DOMAIN is down"
else
echo "$DOMAIN is up"
fi
But I have modified the script to schedule it as a cron job. The modifications are in the if block, which now is:
if [ $? == "1" ]; then
mail -s "[ALARM] $DOMAIN is down" your@email.com
fi
I want to check it every hour so the crontab line is:
0 * * * * /path_to_script/is_up.sh commandliners.com
Obviously, the host where you will run the script will not be the one that you want to check ;)
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>