Skip to main content

Monitoring & Management

Tutorials

Web UI

Overview

  • Ready: 已經發佈到 Queue 的訊息量
  • Unacked: 消費端已接收但尚未 Ack 的訊息量
  • Total: Ready + Unacked

CLI

rabbitmq-diagnostics

Online Resource Utilization

rabbitmq-diagnostics observer

RabbitMQ Version

[root@tpeeaprmq98 ~]# rabbitmq-diagnostics server_version
Asking node rabbit@tpeeaprmq98 for its RabbitMQ version...
3.10.7
rabbitmqctl

List the queues

rabbitmqctl -p <vhost-name> list_queues name state durable arguments policy

rabbitmqctl -qs -p <vhost-name> list_queues name > queue_names.lst

User Management

# List all users
rabbitmqctl list_users

# Create a new user
rabbitmqctl add_user "username"
rabbitmqctl set_permissions -p "custom-vhost" "username" ".*" ".*" ".*"

# Tag the user with "administrator" for full management UI and HTTP API access
rabbitmqctl set_user_tags username administrator

## Verifying the permission
# => Listing permissions for vhost "/" ...
# => user    configure   write   read
# => user2   .*  .*  .*
# => guest   .*  .*  .*
# => temp-user   .*  .*  .*
rabbitmqctl list_permissions --vhost /
rabbitmqctl list_permissions --vhost gw1

Connections

rabbitmqctl list_connections

Recreate the virtual host

rabbitmqctl delete_vhost <my-vhost-name>
rabbltmqctl add_vhost <my-vhost-name>

Reset the RabbitMQ Node

The broker drops all virtual hosts, queues, exchanges, and non-administrative users.

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app

Force Reset the RabbitMQ Node

如果 Cluster 損壞且無法恢復運作時,可以嘗試強制重設 Node。

rabbitmqctl stop_app
rabbitmqctl force_reset
rabbitmqctl start_app

Suspend all listeners and prevent new client connections

rabbitmqctl suspend_listeners

# suspends listeners on node rabbit@node2.cluster.rabbitmq.svc: it won't accept any new client connections
rabbitmqctl suspend_listeners -n rabbit@node2.cluster.rabbitmq.svc

# To resume all listeners on a node and make it accept new client connections again
rabbitmqctl resume_listeners
# resumes listeners on node rabbit@node2.cluster.rabbitmq.svc: it will accept new client connections again
rabbitmqctl resume_listeners -n rabbit@node2.cluster.rabbitmq.svc
rabbitmqadmin

Basic Operation

# List queus
rabbitmqadmin list queues
rabbitmqadmin -H <RabbitMQ-Server-IP> -u <username> -p <password> -V <vhost-name> list queues

# Add a queue with optional parameters
rabbitmqadmin declare queue name=<my-new-queu> durable=true auto_delete=true

Remove multiple queues

rabbitmqadmin -f tsv -q list queues name > q.txt
while read -r name; do rabbitmqadmin -q delete queue name="${name}"; done < q.txt