Skip to content

Instantly share code, notes, and snippets.

@Serpens
Last active December 8, 2015 15:29
Show Gist options
  • Save Serpens/c423cb007f1e1d1ea4d5 to your computer and use it in GitHub Desktop.
Save Serpens/c423cb007f1e1d1ea4d5 to your computer and use it in GitHub Desktop.
Get server status from Uptime Robot
#!/usr/bin/env python
import urllib2
import json
API_KEY = '' # for a single monitor
API_QUERY = 'https://api.uptimerobot.com/getMonitors?apiKey={}&format=json&noJsonCallback=1'
def get_response():
page = urllib2.urlopen(API_QUERY.format(API_KEY))
response = json.loads(page.read())
page.close()
return response['monitors']['monitor'][0]['status'] # '2' is good, '8' and '9' are bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment