Created
October 24, 2013 18:58
-
-
Save anonymous/7143008 to your computer and use it in GitHub Desktop.
pushover notification
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/sh | |
# input validation | |
if [ ! -n "$1" ] | |
then | |
echo “You must enter a url as the first parameter” | |
echo “Usage: $0 <url> <emailaddress>[,<emailaddress>]” | |
exit | |
fi | |
# input validation | |
if [ ! -n "$2" ] | |
then | |
echo “You must enter an email address to notify as the second parameter” | |
echo “Usage: $0 <url> <emailaddress>[,<emailaddress>]” | |
exit | |
fi | |
# the default mail message | |
y=”The following services are broken! Oh noes! ” | |
z=0 | |
# fetch the page and look for the “200″ header | |
x=`wget -O – -q –save-headers $1 | grep “HTTP/1.1 200 OK”` | |
if [ ! -n "$x" ] | |
then | |
y=$y”\n\n$1 ” | |
z=1 | |
fi | |
# if one or more site above triggered an error, send the email | |
if test $z -eq 1 | |
then | |
echo -e $y | mail $2 -s”Server status” | |
instead of email, execute this- | |
curl -s \ | |
-F "token=aheQpU1LFeLo1RNaqTxdMjy4Juh1Ep" \ | |
-F "user=uzpqdT38Bfb5vpNg2GtVvLaS1WofjS" \ | |
-F "message=Deluge Server offline" \ | |
https://api.pushover.net/1/messages.json | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment