Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@urbans
Created April 12, 2012 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbans/2370897 to your computer and use it in GitHub Desktop.
Save urbans/2370897 to your computer and use it in GitHub Desktop.
Send Solaris machine heartbeat to a supervisor on GAE
#!/usr/bin/python
import commands
import httplib
from urllib import urlencode
import time
servername = 'MrSolaris'
data = commands.getoutput('zpool list') + "\r\n\r\n" + "Uptime: " + commands.getoutput('uptime') + "\r\nDate: " + commands.getoutput('date') + "\r\n\r\n" + "Uptime: " + commands.getoutput('zpool status -v')
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')],
['pyserverdate',utc_date_str],
['freesysdisk',commands.getoutput('df -h / | tail -1')],
['freedatadisk1',commands.getoutput('zpool list monkey | tail -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