change the way to filter stats for vhost from http api response.

Somehow, some times, rabbitmq http api fails to get a valid response
with vhost specified, works without vhost, so we filter the stats
for the monitored vhost from the response for all vhosts or api/queues/wq.

Change-Id: I95dbc9b0fca2af88bd6a46c4c112264c37b636c0
This commit is contained in:
Jerry Zhao 2014-10-08 09:28:07 -07:00
parent a519da6974
commit 7099464c5a

View File

@ -53,7 +53,7 @@ def get_stats():
# call http api instead of rabbitmqctl to collect statistics due to issue:
# https://github.com/phrawzty/rabbitmq-collectd-plugin/issues/5
try:
r = requests.get('%s/%s' % (RABBITMQ_API, VHOST),
r = requests.get('%s' % RABBITMQ_API,
auth=('%s' % USER, '%s' % PASS))
# p = subprocess.Popen([RABBITMQCTL_BIN, '-q', '-p', VHOST,
# 'list_queues', 'name', 'messages', 'memory', 'consumers'],
@ -83,6 +83,7 @@ def get_stats():
logger('err', 'No result found for this vhost')
return None
for i in resp:
if i['vhost'] == VHOST:
if "messages" in i:
stats['ctl_messages'] += i['messages']
stats['ctl_messages_%s' % i['name']] = i['messages']