0

I need to monitor rabbitmq cluster status.

REST API doesn't provide information about partitions. So I need to use app rabbitmqctl:

# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbit-1' ...
[{nodes,[{disc,['rabbit@rabbit-1','rabbit@rabbit-2',
                'rabbit@rabbit-3']}]},
 {running_nodes,['rabbit@rabbit-3','rabbit@rabbit-2',
                 'rabbit@rabbit-1']},
 {cluster_name,<<"rabbit@rabbit-1">>},
 {partitions,[]},
 {alarms,[{'rabbit@rabbit-3',[]},
          {'rabbit@rabbit-2',[nodedown]},
          {'rabbit@rabbit-1',[]}]}]

I need to check {partitions,[]},. If there is empty [] it is ok. Otherwise I have problem.

I found example of use erlang from bash:

erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().'  -noshell

Is possible to parse rabbitmqctl stdout using erl (or other tool) and return info "empty / not empty" or return code?

I absolutely don't know Erlang.

If anyone help me, I will be happy :-)

juan.facorro
  • 9,791
  • 2
  • 33
  • 41
martin
  • 1,707
  • 6
  • 34
  • 62
  • You need to drop the first line of input since it's not part of the Erlang term, add a dot `.` at the end of the list, store that into a file and then you can read it with [`file:consult/1`](http://erldocs.com/current/kernel/file.html?i=0&search=file:consult#consult/1). The rest is data manipulation. – juan.facorro Mar 09 '17 at 20:51

1 Answers1

4

you can use this API

http://your_ip:15672/api/nodes

where you can check if a node is up or down

name: "rabbit@t-srv-rabbit-cent04",
type: "disc",
running: false,
+cluster_links: (0)[...],

or partitions

},
-{
-partitions: (0)[
],
os_pid: "8070",
fd_total: 300000,
sockets_total: 269908,
mem_limit: 1590196633,

you don't need erlang shell

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
  • 2
    As an addition, you can choose to display only specific information using the following format: `http://your_ip:15672/api/nodes?columns=name,running,cluster_links` – Mehdi Yedes Jan 29 '18 at 09:39