前面章节介绍了怎样查看队列、交换器、绑定关系、连接、信道和消费者状态信息。下面将介绍更多其他查看状态的命令
在 RabbitMQ 中,可以通过查看 Broker 的状态,比如当前 Erlang 节点上运行的应用程序、RabbitMQ Erlang 的版本信息、操作系统名称、内存及文件描述等统计信息。示例如下:
D:\server\rabbitmq_server-3.9.11\sbin> rabbitmqctl status Status of node rabbit@hxstrive ... Runtime OS PID: 11964 OS: Windows Uptime (seconds): 63342 Is under maintenance?: false RabbitMQ version: 3.9.11 Node name: rabbit@hxstrive Erlang configuration: Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit] Erlang processes: 465 used, 1048576 limit Scheduler run queue: 1 Cluster heartbeat timeout (net_ticktime): 60 Plugins Enabled plugin file: c:/Users/Administrator/AppData/Roaming/RabbitMQ/enabled_plugins Enabled plugins: * rabbitmq_management * amqp_client * rabbitmq_web_dispatch * cowboy * cowlib * rabbitmq_management_agent Data directory Node data directory: c:/Users/Administrator/AppData/Roaming/RabbitMQ/db/rabbit@hxstrive-mnesia Raft data directory: c:/Users/Administrator/AppData/Roaming/RabbitMQ/db/rabbit@hxstrive-mnesia/quorum/rabbit@hxstrive Config files Log file(s) * <stdout> * c:/Users/Administrator/AppData/Roaming/RabbitMQ/log/rabbit@hxstrive.log * c:/Users/Administrator/AppData/Roaming/RabbitMQ/log/rabbit@hxstrive_upgrade.log Alarms (none) Memory Total memory used: 0.073 gb Calculation strategy: rss Memory high watermark setting: 0.4 of available memory, computed to: 6.763 gb code: 0.0358 gb (43.07 %) other_proc: 0.0223 gb (26.85 %) other_system: 0.014 gb (16.91 %) other_ets: 0.0034 gb (4.09 %) plugins: 0.0024 gb (2.94 %) binary: 0.0016 gb (1.97 %) atom: 0.0014 gb (1.71 %) queue_procs: 8.0e-4 gb (0.91 %) mgmt_db: 5.0e-4 gb (0.59 %) metrics: 3.0e-4 gb (0.35 %) connection_other: 2.0e-4 gb (0.21 %) mnesia: 1.0e-4 gb (0.16 %) msg_index: 1.0e-4 gb (0.16 %) connection_readers: 0.0 gb (0.04 %) quorum_ets: 0.0 gb (0.04 %) connection_channels: 0.0 gb (0.01 %) stream_queue_procs: 0.0 gb (0.0 %) stream_queue_replica_reader_procs: 0.0 gb (0.0 %) connection_writers: 0.0 gb (0.0 %) allocated_unused: 0.0 gb (0.0 %) queue_slave_procs: 0.0 gb (0.0 %) quorum_queue_procs: 0.0 gb (0.0 %) reserved_unallocated: 0.0 gb (0.0 %) stream_queue_coordinator_procs: 0.0 gb (0.0 %) File Descriptors Total: 11, limit: 65439 Sockets: 1, limit: 58893 Free Disk Space Low free disk space watermark: 0.05 gb Free disk space: 41.8052 gb Totals Connection count: 1 Queue count: 21 Virtual host count: 4 Listeners Interface: [::], port: 15672, protocol: http, purpose: HTTP API Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0 Interface: 0.0.0.0, port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
我们还可以通过命令对 RabbitMQ 节点进行健康检查,确认应用是否正常运行、list_queues 和 list_channels 是否能够正常返回等等。
示例如下:
D:\server\rabbitmq_server-3.9.11\sbin> rabbitmqctl node_health_check This command is DEPRECATED and will be removed in a future version. It performs intrusive, opinionated health checks and requires a fully booted node. Use one of the options covered in https://www.rabbitmq.com/monitoring.html#health-checks instead. Timeout: 70 seconds ... Checking health of node rabbit@hxstrive ... 16:30:58.439 [warn] rabbitmqctl node_health_check and its HTTP API counterpart are DEPRECATED. See https://www.rabbitmq.com/monitoring.html#health-checks for replacement options. Health check passed
在 RabbitMQ 中,可以通过命令显示每个运行程序环境中每个变量的名称和值。示例如下:
D:\server\rabbitmq_server-3.9.11\sbin> rabbitmqctl environment Application environment of node rabbit@hxstrive ... [{amqp10_common,[]}, {amqp_client, [{prefer_ipv6,false},{ssl_options,[]},{writer_gc_threshold,1000000000}]}, {asn1,[]}, {aten, [{detection_threshold,0.99}, {heartbeat_interval,100}, {poll_interval,5000}, {scaling_factor,1.5}]}, {compiler,[]}, {cowboy,[]}, {cowlib,[]}, ...
在 RabbitMQ 中,可以使用命令为所有服务器状态生成一个服务器状态报告,并将输出重定向到一个文件。示例如下:
D:\server\rabbitmq_server-3.9.11\sbin> rabbitmqctl report Reporting server status of node rabbit@hxstrive ... Status of node rabbit@hxstrive ... Runtime OS PID: 11964 OS: Windows Uptime (seconds): 63727 Is under maintenance?: false RabbitMQ version: 3.9.11 Node name: rabbit@hxstrive Erlang configuration: Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit] Erlang processes: 465 used, 1048576 limit Scheduler run queue: 1 Cluster heartbeat timeout (net_ticktime): 60 Plugins Enabled plugin file: c:/Users/Administrator/AppData/Roaming/RabbitMQ/enabled_plugins Enabled plugins: ... Listing bindings for vhost vhost1... source_name source_kind destination_name destination_kind routing_key arguments exchange queue-hxstrive-1 queue queue-hxstrive-1 [] Listing permissions for vhost "vhost1" ... user configure write read demo .* .* .* hxstrive .* .* .* root .* .* .* guest .* .* .* Listing policies for vhost "vhost1" ... Listing global runtime parameters ... name value internal_cluster_id "rabbitmq-cluster-id-_tHuccm8I-w-kABhHdMINA" Listing runtime parameters for vhost "vhost1" ...
在 RabbitMQ 中,可以通过命令执行任意 Erlang 表达式,例如:
D:\server\rabbitmq_server-3.9.11\sbin> rabbitmqctl eval "date()." {2022,3,26}
上面执行“date().”Erlang 表达式输出当前日期。