Created
June 24, 2015 09:53
-
-
Save polarblau/afb2cfab7bd00f2a6e00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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