rabbitmq list queues on all vhosts
Asked Answered
A

3

9

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?

Android answered 5/5, 2017 at 8:18 Comment(0)
S
16

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
Steric answered 5/5, 2017 at 8:59 Comment(2)
With a few modifications this works beautifully! Thank you!Feldspar
I would suggest an option with few modifications, since the code above doesn't work as is: ``` #!/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 ```Dig
H
8

You can use for i in $(rabbitmqctl list_vhosts); do echo vhost: $i && rabbitmqctl list_queues -p $i; done to just run from the command line

Hoplite answered 29/8, 2018 at 15:54 Comment(0)
T
4

It works for me

rabbitmqctl list_vhosts | xargs -n1  rabbitmqctl list_queues -p
Tiro answered 18/11, 2020 at 13:2 Comment(1)
You need to add the --quiet option otherwise you will run the function on non-existing vhosts for each word in the verbose output in the command.Mishap

© 2022 - 2024 — McMap. All rights reserved.