Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Forked from anonymous/pushover-webcheck
Last active December 26, 2015 11:19
Show Gist options
  • Save michaelminter/7143043 to your computer and use it in GitHub Desktop.
Save michaelminter/7143043 to your computer and use it in GitHub Desktop.
#!/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