Skip to content

Instantly share code, notes, and snippets.

@oremj
Created March 24, 2010 18:27
Show Gist options
  • Save oremj/342591 to your computer and use it in GitHub Desktop.
Save oremj/342591 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from urllib2 import urlopen, URLError
metrics = ['ReqPerSec', 'BytesPerSec', 'BytesPerReq', 'BusyWorkers', 'IdleWorkers']
def get_metrics():
try:
u = urlopen('http://localhost/server-status?auto')
except:
print "status err can't talk to apache"
return
print "status ok everything looks good"
for l in u.readlines():
key, value = (i.strip() for i in l.split(':'))
if key in metrics:
print "metric %s int %d" % (key, float(value))
get_metrics()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment