-
-
Save michaelminter/7143043 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
WGET='/usr/bin/wget' | |
# input validation | |
if [ ! -n "$1" ] | |
then | |
echo "You must enter a url as the first parameter" | |
echo "Usage: $0 <url>" | |
exit | |
fi | |
# the default message | |
y="The following service is unavailable:" | |
${WGET} -O /dev/null --tries=1 $1 | |
if [ $? -eq 0 ]; then | |
echo "Success!" | |
# You could write a log file or something here | |
else | |
echo "Fail! :(" | |
y=$y" $1 " | |
# execute push notification | |
curl -s \ | |
-F "token=aheQpU1LFeLo1RNaqTxdMjy4Juh1Ep" \ | |
-F "user=uzpqdT38Bfb5vpNg2GtVvLaS1WofjS" \ | |
-F "message=$y" \ | |
https://api.pushover.net/1/messages.json | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment