Created
April 12, 2012 20:47
-
-
Save urbans/2370878 to your computer and use it in GitHub Desktop.
Send Linux machine heartbeat to a supervisor on GAE
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/python | |
import commands | |
import httplib | |
from urllib import urlencode | |
import time | |
servername = 'MrPenguin' | |
data = commands.getoutput('df -h') + "\r\n\r\n" + "Uptime: " + commands.getoutput('uptime') + "\r\nDate: " + commands.getoutput("date -R") + "\r\n\r\n" | |
utc_date_str = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) | |
params = dict([ | |
['servername',servername], | |
['uptime', commands.getoutput('uptime')], | |
['serverdate',commands.getoutput('date -R')], | |
['pyserverdate',utc_date_str], | |
['freesysdisk',commands.getoutput('df -h / | tail -n 1')], | |
['fullreport',data]]) | |
h = httplib.HTTPConnection("***************.appspot.com") | |
h.request("POST","/post", urlencode(params)) | |
res = h.getresponse() | |
#print res.status, res.reason |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment