Created
January 8, 2019 09:30
-
-
Save tomvdb/7af06a8d63bbead50032b2186864807d to your computer and use it in GitHub Desktop.
Simple script that checks the online status of a satnogs station and sends a pushover notification if it's offline, Put in crontab at whatever time interval works for (mine is setup for hourly use)
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
# simple script that checks the online status of a satnogs station and sends a pushover notification if it's offline | |
# Put in crontab at whatever time interval works for (mine is setup for hourly use) | |
# 2019/01/08 - Tom Van den Bon (ZR6TG) | |
import requests | |
import httplib, urllib | |
STATION_ID=62 | |
PUSHOVER_USER_KEY = "USERKEY" | |
PUSHOVER_API_KEY = "APIKEY" | |
r = requests.get('https://network.satnogs.org/api/stations/?client_version=&format=json&id=' + str(STATION_ID)) | |
if r.status_code == 200: | |
data = r.json() | |
print data | |
if data[0]["status"] != "Online": | |
print "Station Offline" | |
#send pushover message | |
conn = httplib.HTTPSConnection("api.pushover.net:443") | |
conn.request("POST", "/1/messages.json", | |
urllib.urlencode({ | |
"token": PUSHOVER_API_KEY , | |
"user": PUSHOVER_USER_KEY, | |
"message": "Satnogs Station " + str(STATION_ID) + ", " + data[0]["name"] + " is Offline", | |
}), { "Content-type": "application/x-www-form-urlencoded" }) | |
conn.getresponse() | |
else: | |
print "Station Online" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment