[rabbitmq-discuss] queue message count

Matthias Radestock matthias at lshift.net
Sat Aug 23 18:44:04 BST 2008


Ryan,

Ryan Pratt wrote:
> I am interested in getting total messsage counts for each queue. I want 
> to be able to write a script that monitors the messages per second on 
> the system as a whole and per queue. The stat_all() function gives me a 
> current depth count, but no the total number of messages processed on 
> that queue. Is there a way to get at this value?

There currently isn't.

>If not, could you give 
> me a pointer on where to start looking for adding it in myself? Thanks!

It should be fairly easy to maintain a counter of the total number of 
messages handled by a queue. The code for that would have to go into 
rabbit_amqqueue_process.

You'll need to decide on whether you want to count messages on ingress, 
egress or both - the two are different because messages may get redelivered.

You'll also need to decide what the API should look like. You could 
either extend the rabbit_amqqueue:stat/1 function to return the 
additional information, or introduce a new function.

You may also want to think about what other statistics we may want 
queues to gather. That will help in getting the API right. I reckon 
erlang:process_info/{1,2}, mnesia:system_info/1, and mnesia:table_info/2 
are good examples here w.r.t. overall structure.


Regards,

Matthias




More information about the rabbitmq-discuss mailing list