Skip to content

Instantly share code, notes, and snippets.

@z3cka
Last active December 18, 2015 11:38
Show Gist options
  • Save z3cka/5776749 to your computer and use it in GitHub Desktop.
Save z3cka/5776749 to your computer and use it in GitHub Desktop.
A silly little bash script for checking if a site is up. usage: ./isu.sh sitetocheck.com
#!/bin/sh
siteResponse=`curl -s -I $1 | grep HTTP/1.1 | awk {'print $2'}`
if [ $siteResponse = 200 ]; then
echo "Looks like your site responded with a" $siteResponse "and is fine, be happy!"
else
echo "rut ro! Looks like your site responded with a" $siteResponse "and that's not right, go fix it!"
case $siteResponse in
301 )
echo "aaah, it's a 301, no prob right?";;
500 )
echo $2 "is the email I'm going to try to send to."
echo "yikes! 500! Maybe restart mysql... but I'm just guessing" | mail -s "500 error @ '$1'" "'$2'";;
esac
fi
@z3cka
Copy link
Author

z3cka commented Sep 5, 2013

usage example:

/home/z3cka/isu/isu.sh your-domain-to.check [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment