Created
December 15, 2017 19:45
-
-
Save joshua-chavanne/b852e035caaa2a680e305f0be43723e7 to your computer and use it in GitHub Desktop.
Simple Python Mailgun Upchecker to CRON
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
import requests | |
from datetime import datetime | |
myUrl = 'http://myurl/' | |
def send_simple_message(status): | |
myTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
myText = "As of " + myTime + " the URL "+ myUrl +" is down with a status " + str(status) | |
return requests.post( | |
"API_URL", | |
auth=("api", "API_KEY"), | |
data={"from": "FROM_ADDRESS", | |
"to": ["TO_ADDRESS"], | |
"subject": "URGENT: Site Down", | |
"text": myText}) | |
r = requests.get(myUrl) | |
if r.status_code != 200: | |
send_simple_message(r.status_code) | |
pass | |
if r.status_code == 200: | |
print('all good') | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment