rabbit_mq_info.py 682 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2023/1/3 10:47
  3. # @Author : XuJiakai
  4. # @File : rabbit_mq_info
  5. # @Software: PyCharm
  6. import requests as r
  7. from utils.base_utils import map_2_json_str
  8. rabbit_mq_host = 'http://106.15.78.184:15672'
  9. username = 'whc'
  10. pwd = 'whc'
  11. def get_all_queue_info(host: str = rabbit_mq_host, username: str = username, pwd: str = pwd):
  12. res = r.get(host + '/api/queues', auth=(username, pwd))
  13. data = res.json()
  14. all_info = {}
  15. for i in data:
  16. all_info[i['name']] = i['messages']
  17. return all_info
  18. if __name__ == '__main__':
  19. result_data = get_all_queue_info(rabbit_mq_host, username, pwd)
  20. print(map_2_json_str(result_data))
  21. pass