rabbitmq list queues on all vhosts

Damian Słowiński picture Damian Słowiński · May 5, 2017 · Viewed 24.9k times · Source

I've got rabbitmq with couple virtual hosts, there is few queues on each. How can I list all queues from all vhosts using rabbitmqctl? I've tried:

rabbitmqctl list_queues -p /*
rabbitmqctl list_queues -p *
rabbitmqctl list_queues -p /
rabbitmqctl list_queues -p ./*

Any ideas?

Answer

Gabriele Santomaggio picture Gabriele Santomaggio · May 5, 2017

try with this:

#!/bin/bash
IFS=$'\n'
ordered_vhosts=$(./rabbitmqctl list_vhosts -q | xargs -n1 | sort -u)

for V in $ordered_vhosts; do
    echo "*****Vhost $V Total queues " $(./rabbitmqctl list_queues -q -p $V | wc -l)
    for Q in $(./rabbitmqctl list_queues -q name messages -p $V | xargs -n2 | sort -u); do
        echo "Vhost $V queue-name total-messages $Q"
    done
done