Skip to content

Instantly share code, notes, and snippets.

@ktraff
Last active August 29, 2015 13:57
Show Gist options
  • Save ktraff/9689892 to your computer and use it in GitHub Desktop.
Save ktraff/9689892 to your computer and use it in GitHub Desktop.
Check the status of a website and send an email if it is down
#!/bin/bash
# Script that checks the health status of a website and
# sends notifications if the website is unavailable.
HOST='website.com'
status=`curl -L -o /dev/null --silent --head --write-out '%{http_code}\n' $HOST`
if [ $status != 200 ]; then
echo "$HOST received a status of $status." | mail -s "$HOST is down" "johnsmith@gmail.com"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment