Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Send Linux machine heartbeat to a supervisor on GAE
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([
['uptime', commands.getoutput('uptime')],
['serverdate',commands.getoutput('date -R')],
['freesysdisk',commands.getoutput('df -h / | tail -n 1')],
h = httplib.HTTPConnection("***************")
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