Skip to content

Instantly share code, notes, and snippets.

@polarblau
Created June 24, 2015 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polarblau/afb2cfab7bd00f2a6e00 to your computer and use it in GitHub Desktop.
Save polarblau/afb2cfab7bd00f2a6e00 to your computer and use it in GitHub Desktop.
#!/bin/bash
HOST="some-host.com"
ERROR_MESSAGE="Some Host server unreachable!"
while true
do
status=$(curl -s -I $HOST | grep HTTP/1.1 | awk {'print $2'})
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
if [ $status = 200 ] || [ $status = 401 ]
then
echo "$timestamp -- OK"
else
echo "$timestamp -- $ERROR_MESSAGE"
osascript -e "display notification \"$ERROR_MESSAGE\""
fi
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment