Skip to content

Instantly share code, notes, and snippets.

@eykanal
Created June 27, 2011 14:27
Show Gist options
  • Save eykanal/1048957 to your computer and use it in GitHub Desktop.
Save eykanal/1048957 to your computer and use it in GitHub Desktop.
Simple tool using curl, mailx, and a crontab to monitor whether a site is up or not
#!/bin/sh
# How many seconds does it usually take your site to respond?
sec=2
# Try to download the site to a file
curl -s -m $sec example.org > /tmp/dltime
# Get size of file
a=`wc -m /tmp/dltime | awk '{print $1}'`
# If it didn't download, the file will have size of 0
if [ $a -eq 0 ]; then
# send me a reminder
echo OH SNAP WE\'VE BEEN SLASHDOTTED \
| mailx -s "Server responding slowly" [email protected]
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment