Skip to content

Instantly share code, notes, and snippets.

@lapointexavier
Last active October 26, 2015 16:13
Show Gist options
  • Save lapointexavier/211247a4c644c2df990e to your computer and use it in GitHub Desktop.
Save lapointexavier/211247a4c644c2df990e to your computer and use it in GitHub Desktop.
A dumb script that looks at the Fb api status endpoint
#!/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