Skip to content

Instantly share code, notes, and snippets.

@joshua-chavanne
Created December 15, 2017 19:45
Show Gist options
  • Save joshua-chavanne/b852e035caaa2a680e305f0be43723e7 to your computer and use it in GitHub Desktop.
Save joshua-chavanne/b852e035caaa2a680e305f0be43723e7 to your computer and use it in GitHub Desktop.
Simple Python Mailgun Upchecker to CRON
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