前言
RabbitMQ 有灵活的插件机制,启用 rabbitmq-management 就可以对服务进行监控和管理
RabbitMQ 监控管理是基于 HTTP API 的 WEB GUI 服务,默认开放在 15672 端口,它可以实现以下功能:
- 声明显示和删除 exchanges, queues, bindings, users, virtual hosts and permissions.
- 监控队列长度, 全局和通道上的消息速率, 连接的数据率
- 发送和接收 messages.
- 监控Erlang 进程, 文件描述符, 内存使用情况.
- 导入导出对象的定义到 JSON.
- 强制关闭连接, 清空队列.
下面分享一下 RabbitMQ 监控的基础操作,详细可以参阅 官方文档
Tip: 当前的最新版本为 RabbitMQ 3.6.0 release , 但是示例是 RabbitMQ 3.5.6 release
概要
启用插件
RabbitMQ 有插件机制,从而可以动态灵活地扩展功能和特性
主要是通过 rabbitmq-plugins 来管理的
代码语言:javascript复制[root@rabbitmq ~]# rabbitmq-plugins -h
Error: could not recognise command
Usage:
rabbitmq-plugins [-n <node>] <command> [<command options>]
Commands:
list [-v] [-m] [-E] [-e] [<pattern>]
enable [--offline] [--online] <plugin> ...
disable [--offline] [--online] <plugin> ...
set [--offline] [--online] <plugin> ...
[root@rabbitmq ~]#
启用 rabbitmq_management 插件
代码语言:javascript复制[root@rabbitmq ~]# rabbitmq-plugins list
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on rabbit@rabbitmq
|/
[ ] amqp_client 3.5.6
[ ] cowboy 0.5.0-rmq3.5.6-git4b93c2d
[ ] eldap 3.5.6-gite309de4
[ ] mochiweb 2.7.0-rmq3.5.6-git680dba8
[ ] rabbitmq_amqp1_0 3.5.6
[ ] rabbitmq_auth_backend_ldap 3.5.6
[ ] rabbitmq_auth_mechanism_ssl 3.5.6
[ ] rabbitmq_consistent_hash_exchange 3.5.6
[ ] rabbitmq_federation 3.5.6
[ ] rabbitmq_federation_management 3.5.6
[ ] rabbitmq_management 3.5.6
[ ] rabbitmq_management_agent 3.5.6
[ ] rabbitmq_management_visualiser 3.5.6
[ ] rabbitmq_mqtt 3.5.6
[ ] rabbitmq_shovel 3.5.6
[ ] rabbitmq_shovel_management 3.5.6
[ ] rabbitmq_stomp 3.5.6
[ ] rabbitmq_test 3.5.6
[ ] rabbitmq_tracing 3.5.6
[ ] rabbitmq_web_dispatch 3.5.6
[ ] rabbitmq_web_stomp 3.5.6
[ ] rabbitmq_web_stomp_examples 3.5.6
[ ] sockjs 0.3.4-rmq3.5.6-git3132eb9
[ ] webmachine 1.10.3-rmq3.5.6-gite9359c7
[root@rabbitmq ~]# netstat -ant | grep 15672
[root@rabbitmq ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to rabbit@rabbitmq... started 6 plugins.
[root@rabbitmq ~]# rabbitmq-plugins list
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on rabbit@rabbitmq
|/
[e*] amqp_client 3.5.6
[ ] cowboy 0.5.0-rmq3.5.6-git4b93c2d
[ ] eldap 3.5.6-gite309de4
[e*] mochiweb 2.7.0-rmq3.5.6-git680dba8
[ ] rabbitmq_amqp1_0 3.5.6
[ ] rabbitmq_auth_backend_ldap 3.5.6
[ ] rabbitmq_auth_mechanism_ssl 3.5.6
[ ] rabbitmq_consistent_hash_exchange 3.5.6
[ ] rabbitmq_federation 3.5.6
[ ] rabbitmq_federation_management 3.5.6
[E*] rabbitmq_management 3.5.6
[e*] rabbitmq_management_agent 3.5.6
[ ] rabbitmq_management_visualiser 3.5.6
[ ] rabbitmq_mqtt 3.5.6
[ ] rabbitmq_shovel 3.5.6
[ ] rabbitmq_shovel_management 3.5.6
[ ] rabbitmq_stomp 3.5.6
[ ] rabbitmq_test 3.5.6
[ ] rabbitmq_tracing 3.5.6
[e*] rabbitmq_web_dispatch 3.5.6
[ ] rabbitmq_web_stomp 3.5.6
[ ] rabbitmq_web_stomp_examples 3.5.6
[ ] sockjs 0.3.4-rmq3.5.6-git3132eb9
[e*] webmachine 1.10.3-rmq3.5.6-gite9359c7
[root@rabbitmq ~]# netstat -ant | grep 15672
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN
[root@rabbitmq ~]# curl http://localhost:15672
<html>
<head>
<title>RabbitMQ Management</title>
<script src="js/ejs.min.js" type="text/javascript"></script>
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="js/jquery.flot.min.js" type="text/javascript"></script>
<script src="js/jquery.flot.time.min.js" type="text/javascript"></script>
<script src="js/sammy-0.6.0.min.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script src="js/base64.js" type="text/javascript"></script>
<script src="js/global.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
<script src="js/prefs.js" type="text/javascript"></script>
<script src="js/help.js" type="text/javascript"></script>
<script src="js/formatters.js" type="text/javascript"></script>
<script src="js/charts.js" type="text/javascript"></script>
<link href="css/main.css" rel="stylesheet" type="text/css"/>
<!--<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>-->
<!--[if lte IE 8]>
<script src="js/excanvas.min.js" type="text/javascript"></script>
<link href="css/evil.css" rel="stylesheet" type="text/css"/>
<![endif]-->
</head>
<body>
<div id="outer"></div>
<div id="debug"></div>
<div id="scratch"></div>
</body>
</html>
[root@rabbitmq ~]#