Skip to content

Instantly share code, notes, and snippets.

@sacreman
Created July 22, 2015 11:02
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 sacreman/9e7fce760e355b24985d to your computer and use it in GitHub Desktop.
Save sacreman/9e7fce760e355b24985d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import requests
import xmltodict
USER = ''
PASSWORD = ''
xml = requests.get('http://%s:%s@localhost:8161/admin/xml/queues.jsp' % (USER, PASSWORD)).text
obj = xmltodict.parse(xml)
result = {}
for queue in obj['queues']['queue']:
_name = queue['@name']
_feed = queue['feed']['atom']
result[_name + '_size'] = queue['stats']['@size']
result[_name + '_consumer_count'] = queue['stats']['@consumerCount']
result[_name + '_enqueue_count'] = queue['stats']['@enqueueCount']
result[_name + '_dequeue_count'] = queue['stats']['@dequeueCount']
feed_xml = requests.get('http://%s:%s@localhost:8161/admin/' % (USER, PASSWORD) + _feed).text
try:
feed_obj = xmltodict.parse(feed_xml)['feed']['entry']
print _name, feed_obj['published']
except:
pass
output = ''
for k, v in result.iteritems():
n = "%s=%s;;;; " % (k, v)
output += n
print "OK | " + output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment