Sumanth
Sumanth

Reputation: 29

How to understand the output of rabbitmqctl commands

$rabbitmqctl list_queues

Timeout: 60.0 seconds ...
Listing queues for vhost / ...
privateTransactionQ 2
amq.gen-o9dl3Zj7HxS50gkTC2xbBQ  0
task_queue  0

Output of rabbitmqctl looks like this. I cant make out what each column is meant for. How can I see the meaning of each column?

Upvotes: 1

Views: 3436

Answers (1)

P.vlad
P.vlad

Reputation: 83

There is no "easy" solution for this, but we're IT and we can build them. I'm not an expert in RabbitMQ nor in programming, but I'll give my best to give a good answer to this one, just in case someone lands in here looking for help.

Let's take the exact case of listing the queues from rabbitmqctl console. By typing "rabbitmqctl" you get the list of available commands:

Commands: 
[...]
list_queues [-p <vhost>] [--online] [--offline] [--local] [<queueinfoitem> ...] [-t <timeout>]
[...] 

Assuming you know what a vhost and queue are, let's say you want to list all the queues in vhost "TEST", then you would need to type:

> rabbitmqctil list_queues -p TEST 
Timeout: 60.0 seconds ...
Listing queues for vhost TEST ...
test.queue 0

By default, you only get the "name" of the queue and its "current depth". Where do you find all the parameters of the queues? Pay special attention to the word "queueinfoitem" in the help instruction you typed first. If you see the rabbitmqctl help instructions (by typing "rabbitmqctl"), at the end of the instruction you can see a list of available options for the parameter "".

Now let's see an example where you want to see a more advanced status of the queue, per say: messages ready in queues, messages in status unacknowledged, messages RAM, consumers, consumer's memory utilization, state of the queue and of course, its name.

You are right about one thing: rabbitmqctl doesn't return the result in a friendly way. By default, you get this:

rabbitmqctl list_queues -p TEST  messages_ready, messages_unacknowledged, messages_ram, consumers, consumer_utilisation, state, name
Timeout: 60.0 seconds ...
Listing queues for vhost TEST ...
0       0       0       0               running test.queue

But with a bit of immagination, you can achieve this:

----------------------------------------------------------
Msg. * Msg. * Msg. **       ** Cons. **         **** Name
Rdy * Unack * RAM *** Cons.  * Util. ** State    ***
----------------------------------------------------------
0       0       0       0               running     test.queue

It's no big deal, but it's better than the default. I achieved that with a small python script:

import os
vhosts = os.popen("rabbitmqctl list_vhosts name").read() 
logging.info(vhosts)
vhosts = vhosts.split("\n",1)[1]
vhosts = vhosts[:-1]
vhosts = vhosts.split("\n")
for vhost in vhosts: 
    header_a = "Msg. * Msg. * Msg. **       ** Cons. **         **** Name\n" 
    header_b = "Rdy * Unack * RAM *** Cons.  * Util. ** State    ***     \n"
    dash = "----------------------------------------------------------\n"
    queues = os.popen("rabbitmqctl list_queues -p " + vhost + " messages_ready, messages_unacknowledged, messages_ram, consumers, consumer_utilisation, state, name").read() 
    queues = queues.split("\n",2)[2]
    queues_list = dash + header_a + header_b + dash + queues
    print(queues_list)

Of course this can be improved in so many ways and critics are always welcome, I still hope it helps someone.

Cheers.

Upvotes: 7

Related Questions