The management plugin ships with a command line tool rabbitmqadmin which can perform the same actions as the web-based UI, and which may be more convenient for use when scripting. Note that rabbitmqadmin is just a specialised HTTP client; if you are contemplating invoking rabbitmqadmin from your own program you may want to consider using the HTTP API directly.
With the management plugin installed, browse to http://server-name:55672/cli/ to download. You will need Python 2.x, 2.6 or later (i.e. not Python 3).
Alternatively, you can download the version of rabbitmqadmin which corresponds with the management plugin version 2.8.2 here.
Unix users will probably want to copy rabbitmqadmin to /usr/local/bin.
Windows users will need to ensure Python is on their path, and invoke rabbitmqadmin as python.exe rabbitmqadmin.
Invoke rabbitmqadmin --help for usage instructions. You can:
rabbitmqadmin supports tab completion in bash. To print a bash completion script, invoke rabbitmqadmin --bash-completion. This should be redirected to a file and sourced.
On Debian-derived systems, copy the file to /etc/bash_completion.d to make it available system-wide:
sudo sh -c 'rabbitmqadmin --bash-completion > /etc/bash_completion.d/rabbitmqadmin'
$ rabbitmqadmin -V test list exchanges
+-------------+---------+-------+---------+-------------+
| name | durable | vhost | type | auto_delete |
+-------------+---------+-------+---------+-------------+
| | True | test | direct | False |
| amq.direct | True | test | direct | False |
| amq.fanout | True | test | fanout | False |
| amq.headers | True | test | headers | False |
| amq.match | True | test | headers | False |
| amq.topic | True | test | topic | False |
+-------------+---------+-------+---------+-------------+
$ rabbitmqadmin list queues vhost name node messages message_stats.publish_details.rate
+-------+----------------------------------+-------------------+----------+------------------------------------+
| vhost | name | node | messages | message_stats.publish_details.rate |
+-------+----------------------------------+-------------------+----------+------------------------------------+
| / | amq.gen-UELtxwb8OGJ9XHlHJq0Jug== | rabbit@smacmullen | 0 | 100.985821591 |
| / | test | rabbit@misstiny | 5052 | 100.985821591 |
+-------+----------------------------------+-------------------+----------+------------------------------------+
$ rabbitmqadmin -f long -d 3 list queues
--------------------------------------------------------------------------------
vhost: /
name: amq.gen-UELtxwb8OGJ9XHlHJq0Jug==
auto_delete: False
backing_queue_status.avg_ack_egress_rate: 100.944672225
backing_queue_status.avg_ack_ingress_rate: 100.944672225
and so on, and on...
$ rabbitmqadmin -H myserver -u simon -p simon list vhosts
+------+
| name |
+------+
| / |
+------+
$ rabbitmqadmin declare exchange name=my-new-exchange type=fanout
exchange declared
$ rabbitmqadmin declare queue name=my-new-queue durable=false
queue declared
$ rabbitmqadmin publish exchange=amq.default routing_key=test payload="hello, world"
Message published
$ rabbitmqadmin get queue=test requeue=false
+-------------+----------+---------------+--------------+------------------+-------------+
| routing_key | exchange | message_count | payload | payload_encoding | redelivered |
+-------------+----------+---------------+--------------+------------------+-------------+
| test | | 0 | hello, world | string | False |
+-------------+----------+---------------+--------------+------------------+-------------+
$ rabbitmqadmin export rabbit.config
Exported configuration for localhost to "rabbit.config"
$ rabbitmqadmin -q import rabbit.config
$ rabbitmqadmin -f tsv -q list connections name | while read conn ; do rabbitmqadmin -q close connection name=${conn} ; done