Arun
Arun

Reputation: 81

How to get rabbitmq cluster status in json format

How to get status and cluster_status from rabbitmq in JSON format

sudo rabbitmqctl status
sudo rabbitmqctl cluster_status

Upvotes: 1

Views: 2614

Answers (2)

Arun
Arun

Reputation: 81

Figured out by myself. You can use the option --formatter json Could not find it in the rabbitmq documentation!

sudo rabbitmqctl cluster_status --formatter json
sudo rabbitmqctl cluster_status --formatter json | jq .running_nodes

To parse this and use it in bash script:

running_nodes=($(egrep -o '[a-z0-9@-]+' <<< $(sudo rabbitmqctl cluster_status --formatter json | jq .running_nodes)))

Upvotes: 2

Luke Bakken
Luke Bakken

Reputation: 9637

help is your friend:

# rabbitmqctl help cluster_status
Error:

Usage

rabbitmqctl [--node <node>] [--longnames] [--quiet] cluster_status

Displays all the nodes in the cluster grouped by node type, together with the currently running nodes.


Relevant Doc Guides

 * https://rabbitmq.com/clustering.html

 * https://rabbitmq.com/cluster-formation.html

 * https://rabbitmq.com/monitoring.html


General Options

The following options are accepted by most or all commands.

short            | long          | description
-----------------|---------------|--------------------------------
-?               | --help        | displays command help
-n <node>        | --node <node> | connect to node <node>
-l               | --longnames   | use long host names
-t               | --timeout <n> | for commands that support it, operation timeout in seconds
-q               | --quiet       | suppress informational messages
-s               | --silent      | suppress informational messages
                                 | and table header row
-p               | --vhost       | for commands that are scoped to a virtual host,
                 |               | virtual host to use
                 | --formatter   | alternative result formatter to use
                                 | if supported: json, pretty_table, table, csv.
                                   not all commands support all (or any) alternative formatters.

Upvotes: 1

Related Questions