Chapter 7. Monitoring

A lot of software systems among the ones we use nowadays run on our server instances. Each software system uses resources such as memory, CPU, and so on. Therefore, we should check the resource usage of each software system. We now come to the definition of monitoring. Monitoring simply means reporting or checking the software systems, their resource usage, and alerting when these levels reach a critical level so that the issue can be addressed. We need to monitor all our software systems all the time; therefore, we should monitor our RabbitMQ server too.

RabbitMQ gives us amazing tools, such as the command-line application called rabbitmqctl and the management web plugin. Furthermore, we also have general tools for the monitoring of server instances such as Nagios, Munin, Zabbix, and so on. In this chapter, we will look at each of the following monitoring tools one by one:

  • The rabbitmqctl command-line application
  • Management plugin
  • Nagios
  • Munin
  • Zabbix

RabbitMQ command-line tools

RabbitMQ's powerful command-line tools have lots of skills, such as controlling, managing, and monitoring. One of the command-line tools of RabbitMQ, rabbitmqctl, gives us an opportunity to monitor the RabbitMQ in real-time. We use the rabbitmqctl tool for its monitoring functions, such as reporting on the RabbitMQ and displaying the status and specific functions of RabbitMQ.

The report function of the rabbitmqctl tool shows lots of details of RabbitMQ in realtime. The report function shows the sum of all monitoring results of the other functions of rabbitmqctl. We can find the running environment variables, configuration parameters, and cluster statuses, as shown in the next command block.

Moreover, the report function shows the current state of each functional structure of RabbitMQ, such as connections to RabbitMQ, channels in RabbitMQ, and so on, as shown in the following code:

Cluster status of node rabbit@localhost ...
[{nodes,[{disc,[rabbit@localhost]}]},
 {running_nodes,[rabbit@localhost]},
 {cluster_name,<<"rabbit@yaytas">>},
 {partitions,[]}]

Application environment of node rabbit@localhost ...
[{amqp_client,[{prefer_ipv6,false},{ssl_options,[]}]},
 {inets,[]},
 {kernel,
     [{error_logger,tty},
      {inet_default_connect_options,[{nodelay,true}]},
      {inet_dist_listen_max,25672},{inet_dist_listen_min,25672}]},
 {mnesia,[{dir,"/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost"}]},
 {mochiweb,[]},
 {os_mon,
     [{start_cpu_sup,false},
      {start_disksup,false},
      {start_memsup,false},
      {start_os_sup,false}]},
 {rabbit,
     [{auth_backends,[rabbit_auth_backend_internal]},
      {auth_mechanisms,['PLAIN','AMQPLAIN']},
      {backing_queue_module,rabbit_priority_queue},
      {channel_max,0},
      {cluster_keepalive_interval,10000},
      {cluster_nodes,{[],disc}},
      {cluster_partition_handling,ignore},
      {collect_statistics,fine},
      {collect_statistics_interval,5000},
      {credit_flow_default_credit,{200,50}},
      {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
      {default_user,<<"guest">>},
      {default_user_tags,[administrator]},
      {default_vhost,<<"/">>},
      {delegate_count,16},
      {disk_free_limit,50000000},

On the other hand, RabbitMQ gives us another way to monitor each of the reporting items one by one. As shown in the next command block, we can monitor the running instance, configuration properties, and modules that run on the current RabbitMQ with the help of the status function of the rabbitmqctl tool:

Cluster status of node rabbit@localhost ...
[{nodes,[{disc,[rabbit@localhost]}]},
 {running_nodes,[rabbit@localhost]},
 {cluster_name,<<"rabbit@yaytas">>},
 {partitions,[]}]

Application environment of node rabbit@localhost ...
[{amqp_client,[{prefer_ipv6,false},{ssl_options,[]}]},
 {inets,[]},
 {kernel,
     [{error_logger,tty},
      {inet_default_connect_options,[{nodelay,true}]},
      {inet_dist_listen_max,25672},{inet_dist_listen_min,25672}]},
 {mnesia,[{dir,"/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost"}]},
 {mochiweb,[]},
 {os_mon,
     [{start_cpu_sup,false},
      {start_disksup,false},
      {start_memsup,false},
      {start_os_sup,false}]},
 {rabbit,
     [{auth_backends,[rabbit_auth_backend_internal]},
      {auth_mechanisms,['PLAIN','AMQPLAIN']},
      {backing_queue_module,rabbit_priority_queue},
      {channel_max,0},
      {cluster_keepalive_interval,10000},
      {cluster_nodes,{[],disc}},
      {cluster_partition_handling,ignore},
      {collect_statistics,fine},
      {collect_statistics_interval,5000},
      {credit_flow_default_credit,{200,50}},
      {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
      {default_user,<<"guest">>},
      {default_user_tags,[administrator]},
      {default_vhost,<<"/">>},
      {delegate_count,16},
      {disk_free_limit,50000000},

yaytas:~ yaytas$ rabbitmqctl status
Status of node rabbit@localhost ...
[{pid,9430},
 {running_applications,
     [{rabbitmq_management_visualiser,"RabbitMQ Visualiser","3.5.5"},
      {rabbitmq_management,"RabbitMQ Management Console","3.5.5"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.5"},
      {webmachine,"webmachine","1.10.3-rmq3.5.5-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.5-git680dba8"},
      {rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.5.5"},
      {rabbitmq_stomp,"Embedded Rabbit Stomp Adapter","3.5.5"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.5.5"},
      {rabbitmq_amqp1_0,"AMQP 1.0 support for RabbitMQ","3.5.5"},
      {rabbit,"RabbitMQ","3.5.5"},
      {mnesia,"MNESIA  CXC 138 12","4.12.5"},
      {os_mon,"CPO  CXC 138 46","2.3.1"},
      {inets,"INETS  CXC 138 49","5.10.6"},
      {amqp_client,"RabbitMQ AMQP Client","3.5.5"},
      {xmerl,"XML parser","1.3.7"},
      {sasl,"SASL  CXC 138 11","2.4.1"},
      {stdlib,"ERTS  CXC 138 10","2.4"},
      {kernel,"ERTS  CXC 138 10","3.2"}]},
 {os,{unix,darwin}},
 {erlang_version,
     "Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:64] [hipe] [kernel-poll:true]
"},
 {memory,
     [{total,43373712},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,5616},
      {queue_procs,2808},
      {queue_slave_procs,0},
      {plugins,623056},
      {other_proc,13892360},
      {mnesia,62400},
      {mgmt_db,171400},
      {msg_index,47680},
      {other_ets,1274264},
      {binary,16128},
      {code,20748464},
      {atom,711569},
      {other_system,5817967}]},
 {alarms,[]},
 {listeners,
     [{clustering,25672,"::"},
      {amqp,5672,"127.0.0.1"},
      {stomp,61613,"::"},
      {mqtt,1883,"::"}]},
 {vm_memory_high_watermark,0.4},
{vm_memory_limit,6216758067},
 {disk_free_limit,50000000},
 {disk_free,197295443968},
 {file_descriptors,
     [{total_limit,156},{total_used,5},{sockets_limit,138},{sockets_used,3}]},
 {processes,[{limit,1048576},{used,200}]},
 {run_queue,0},
 {uptime,754}]

Starting from the status function, we'll look at the current RabbitMQ interactions. For instance, we need to monitor the current consumers in our RabbitMQ server instance. As the rabbitmqctl tool lets us list all the consumers within the server instance using the list_consumers function, as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_consumers
Listing consumers ...
stm.performance.queue <[email protected]> amq.ctag-PNwQde_aIWdpB2KVwTAG8A	true []
stm.performance.queue <[email protected]> amq.ctag-P7VHTEYl-emdaPkfsYRlXw true []
...done.

Moreover, we sometimes need to check the current channels on the RabbitMQ server. As shown in the following command line, the rabbitmqctl tool allows us to monitor the current channels on the server instance using the list_channels function:

vagrant@precise32:~$ sudo rabbitmqctl list_channels
Listing channels ...
<[email protected]> guest 1 0
<[email protected]> guest 1 0
...done.

Furthermore, we should check the current connected users. The rabbitmqctl tool gives us another way to list the current connected users using the list_connections function of RabbitMQ, as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_connections
Listing connections ...
guest 10.0.2.2 59144 running
...done.

Additionally, we have to control the current bindings on our queues in the RabbitMQ instance. To monitor bindings on the RabbitMQ queues, we can use rabbitmqctl to monitor the current bindings using the list_bindings function as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_bindings
Listing bindings ...
exchange stm.performance.queue queue stm.performance.queue []
...done.

Exchanges are the most important functions of the RabbitMQ. We can control and monitor the current exchanges. Therefore, the rabbitmqctl tool gives us another function to monitor the current exchanges using list_exchanges, as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_exchanges
Listing exchanges ...
direct
amq.direct direct
amq.fanout fanout
amq.headers headers
amq.match headers
amq.rabbitmq.log topic
amq.rabbitmq.trace topic
amq.topic topic
...done.

As we know that the queues are the main data structure of the message brokers, we need to check the current queues on the RabbitMQ server instance. The following command line simply describes the current queues on the RabbitMQ server instance using rabbitmqctl's list_queues function:

vagrant@precise32:~$ sudo rabbitmqctl list_queues
Listing queues ...
stm.performance.queue 0
...done.

Permissions are used for controlling the access for the different modules of the RabbitMQ server. Permissions are covered in detail in Chapter 8, Security in RabbitMQ. We should check the current permissions of the users on the RabbitMQ server instance. Then, we come to rabbitmqctl's function for listing permissions, that is, list_permissions:

vagrant@precise32:~$ sudo rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
guest .* .* .*
monit .* .* .*
monitor .* .* .*
...done.

With the list_permissions function, we are able to list the permissions of the users. Additionally, we need to list the current users with their tags that are related with their roles. The rabbitmqctl tool gives us another function to list users, that is, the list_users function, as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_users
Listing users ...
guest [administrator]
monit [administrator]
monitor [monitoring]
...done.

Finally, we need to list the virtual hosts on the RabbitMQ server instance. Our powerful rabbitmqctl tool gives us another great function called list_vhosts to list all the virtual hosts as shown in the following command line:

vagrant@precise32:~$ sudo rabbitmqctl list_vhosts
Listing vhosts ...
/
...done.

As we looked into the details of each of the function of RabbitMQ's powerful control and monitoring command line called rabbitmqctl, we are able to monitor each statistical information and details of the RabbitMQ with real-time support.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset