Last active
October 26, 2015 16:13
-
-
Save lapointexavier/211247a4c644c2df990e to your computer and use it in GitHub Desktop.
A dumb script that looks at the Fb api status endpoint
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
#!/usr/bin/env python | |
import time | |
import logging | |
import pync | |
import requests | |
log = logging.getLogger(__name__) | |
url = 'https://www.facebook.com/feeds/api_status.php' | |
sleep_ok = 1000 | |
sleep_bad = 180 | |
def main(): | |
while True: | |
resp = requests.get(url) | |
if resp.status_code != 200: | |
log.error('Facebook status api puked: %s', resp.content) | |
time.sleep(sleep_bad) | |
continue | |
data = resp.json() | |
current = data.get('current') | |
if current: | |
if current.get('health') == 1: | |
pync.Notifier.notify(current.get('subject'), title='Facebook Status') | |
time.sleep(sleep_ok) | |
else: | |
pync.Notifier.notify(current.get('subject'), title='Facebook Issue!') | |
time.sleep(sleep_bad) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment