author:headsen chen
date: 2019-07-26 17:22:24
notice: 个人原创
import requests, json, time, datetime from requests.auth import HTTPBasicAuth username = ‘xxxxx' password = 'yyyyyyy' queue_url = 'http://xxxxxxx:15672/api/queues' res = requests.get(url=queue_url, auth=HTTPBasicAuth(username=username, password=password)) if res.status_code == 200: queues = json.loads(res.text) iswarnning = False msg = u"%s rabbitmq消息队列堆积异常: " % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),) for queue in queues: queue_count = int(queue.get("messages", 0)) if queue_count>100000: print(queue['name'],queue_count)