Skip to content

Instantly share code, notes, and snippets.

@stevehenderson
Last active March 22, 2022 03:36
Show Gist options
  • Save stevehenderson/2fee04f3482ad27ac4a4e75905dcc96f to your computer and use it in GitHub Desktop.
Save stevehenderson/2fee04f3482ad27ac4a4e75905dcc96f to your computer and use it in GitHub Desktop.
UptimeBot Heartbeat Script
import requests
import time
def contact_monitor():
print("Calling the monitor...")
r= requests.get("https://heartbeat.uptimerobot.com/m11111111-11111111111111111111111111")
while 1==1:
time.sleep(30)
try:
r = requests.get("https://mysite.onlyreachable.insi.de")
if r.text == "What my service returns normally":
contact_monitor()
except Exception as e:
print("Exception while monitoring {}".format(e))
@stevehenderson
Copy link
Author

Run this under pm2:

pm2 start "python3 -u uptime_bot_heartbeat.py"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment