Last active
December 8, 2015 15:29
-
-
Save Serpens/c423cb007f1e1d1ea4d5 to your computer and use it in GitHub Desktop.
Get server status from Uptime Robot
This file contains 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
#!/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