Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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