SweetEriri

Rabbitmq统计单个queue消息数量的脚本

#!/bin/env python

# -*- coding: UTF-8 -*-

import sys, urllib2, base64, json, re,time
ip = ""
keys = ('messages_ready',)
def GetRabbitmqData():
        request = urllib2.Request("http://%s:15672/api/queues" % ip)
        base64string = base64.b64encode('guest:guest')
        request.add_header("Authorization", "Basic %s" % base64string)
        result = urllib2.urlopen(request)
        data = json.loads(result.read())
        return data
data=GetRabbitmqData()

#print data

for queue in data:
    try:
        print "消费者数量:",queue['consumers'],"队列:",queue['name'],"消息积压数:",int(queue[keys[0]])
    except:
        pass

发表评论

评论列表,共 1 条评论

  • DannyLoamb
    BTC may be the latest or last chance to get rich in this era. It will reach $200000 next year or the next year. Think about only $2 a few years ago. Come to the world's largest and safest virtual currency exchange to reduce the handling fee. Don't miss the most important opportunity in life https://hi.switchy.io/5dyf