Как получить статус кластера rabbitmq в формате json - PullRequest
0 голосов
/ 24 сентября 2019

Как получить статус и cluster_status из rabbitmq в формате JSON

sudo rabbitmqctl status
sudo rabbitmqctl cluster_status

Ответы [ 2 ]

2 голосов
/ 25 сентября 2019

help ваш друг:

# 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.
1 голос
/ 24 сентября 2019

Разобрался сам.Вы можете использовать параметр --formatter json Не удалось найти его в документации rabbitmq !

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

Чтобы проанализировать это и использовать его в сценарии bash:

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...