rabbitmq list queues on all vhosts

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

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