rabbitmqadmin 使用方法

作用

一个可以对 rabbitmq 进行监控的 python 脚本

获取方法

curl http://rabbitmq-server:15672/cli/rabbitmqadmin > rabbitmqadmin

该工具只是一种用于访问 rabbitmq-server api 便捷方式
工具主要获取了 rabbitmq api 接口, 接口信息参见该脚本中 URIS 字典信息
方便在 cli 环境下获取 rabbitmq server 状态信息而已
支持对 api 执行 get, put, post, delete 方法访问,意味着可以获取,修改,更新 rabbitmq 服务器状态

配置方法

参考 config_usage() 进行配置
配置文件 radmin.conf

[host_normal]
hostname = localhost
port = 15672
username = admin
password = admin
declare_vhost = / # Used as default for declare / delete only
vhost = / 

rabbitmqadmin 使用方法

获取本地队列

[root@mailtest-8vnaw ~]# ./rabbitmqadmin --config=rabbitmqadmin.conf  list exchanges
+-------+--------------------+---------+-------------+---------+----------+--------+
| vhost |        name        |  type   | auto_delete | durable | internal | policy |
+-------+--------------------+---------+-------------+---------+----------+--------+
| /     |                    | direct  | False       | True    | False    | ha-all |
| /     | amq.direct         | direct  | False       | True    | False    |        |
| /     | amq.fanout         | fanout  | False       | True    | False    |        |
| /     | amq.headers        | headers | False       | True    | False    |        |
| /     | amq.match          | headers | False       | True    | False    |        |
| /     | amq.rabbitmq.log   | topic   | False       | True    | True     |        |
| /     | amq.rabbitmq.trace | topic   | False       | True    | True     |        |
| /     | amq.topic          | topic   | False       | True    | False    |        |
| /     | mq-test            | fanout  | False       | True    | False    | ha-all |
| /     | python-test        | fanout  | False       | True    | False    | ha-all |
| /     | win-test           | fanout  | False       | False   | False    | ha-all |
+-------+--------------------+---------+-------------+---------+----------+--------+

查询队列状态信息

 ./rabbitmqadmin --config=rabbitmqadmin.conf list queues vhost name node messages message_stats.publish_details.rate
+-------+-------------+-------------------------------+----------+------------------------------------+
| vhost |    name     |             node              | messages | message_stats.publish_details.rate |
+-------+-------------+-------------------------------+----------+------------------------------------+
| /     | mq-test     | rabbit@terry-zabbixtest-xyndf |          |                                    |
| /     | python-test | rabbit@terry-zabbixtest-xyndf |          |                                    |
| /     | win-test    | rabbit@mailtest-8vnaw         | 60329    | 0.0                                |
+-------+-------------+-------------------------------+----------+------------------------------------+

获取队列最近消费详细信息
./rabbitmqadmin --config=rabbitmqadmin.conf -f long -d 3 list queues

--------------------------------------------------------------------------------

                                    vhost: /
                                     name: win-test
                              auto_delete: False
 backing_queue_status.avg_ack_egress_rate: 3.09872133306e-25
backing_queue_status.avg_ack_ingress_rate: 1.58476984784e-25
     backing_queue_status.avg_egress_rate: 1.58476984784e-25
    backing_queue_status.avg_ingress_rate: 59.2546229203
               backing_queue_status.delta: ["delta", "undefined", 0, "undefined"]
                 backing_queue_status.len: 60329
         backing_queue_status.mirror_seen: 0
      backing_queue_status.mirror_senders: 0
         backing_queue_status.next_seq_id: 17731285
        backing_queue_status.pending_acks: 0
    backing_queue_status.persistent_count: 60329
                  backing_queue_status.q1: 0
                  backing_queue_status.q2: 0
                  backing_queue_status.q3: 0
                  backing_queue_status.q4: 60329
       backing_queue_status.ram_ack_count: 0
       backing_queue_status.ram_msg_count: 60329
    backing_queue_status.target_ram_count: infinity
                     consumer_utilisation:
                                consumers: 0
                                  durable: True
                   exclusive_consumer_tag:
                               idle_since: 2020-07-02 9:52:49
                                   memory: 59420008                                <-- 占用内存数量
                        message_stats.ack: 17670896
           message_stats.ack_details.rate: 0.0
                    message_stats.deliver: 17687356
       message_stats.deliver_details.rate: 0.0
                message_stats.deliver_get: 17687416                                <-  已被 customer 完成接收的消息
   message_stats.deliver_get_details.rate: 0.0
             message_stats.deliver_no_ack: 60
message_stats.deliver_no_ack_details.rate: 0.0
                    message_stats.publish: 17731285
       message_stats.publish_details.rate: 0.0
                  message_stats.redeliver: 16460
     message_stats.redeliver_details.rate: 0.0
                                 messages: 60329                                     <--- 已推送到server 但未被 customer 消费确认
                    messages_details.rate: 0.0
                           messages_ready: 60329                                     <-- 可用于 delivery 的消息队列
              messages_ready_details.rate: 0.0                                       <-- 信息 ready 的比例
                  messages_unacknowledged: 0
     messages_unacknowledged_details.rate: 0.0
                                     node: rabbit@mailtest-8vnaw
                                   policy: ha-all
                              slave_nodes: rabbit@terry-zabbixtest-xyndf
                                    state: running
                 synchronised_slave_nodes: rabbit@terry-zabbixtest-xyndf
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值