2017-03-09 76 views
0

我需要監視rabbitmq羣集狀態。RabbitMQ集羣狀態:如何從外殼中解析Erlang的梁?

REST API不提供有關partitions的信息。所以,我需要使用的應用程序rabbitmqctl

# rabbitmqctl cluster_status 
Cluster status of node '[email protected]' ... 
[{nodes,[{disc,['[email protected]','[email protected]', 
       '[email protected]']}]}, 
{running_nodes,['[email protected]','[email protected]', 
       '[email protected]']}, 
{cluster_name,<<"[email protected]">>}, 
{partitions,[]}, 
{alarms,[{'[email protected]',[]}, 
      {'[email protected]',[nodedown]}, 
      {'[email protected]',[]}]}] 

我需要檢查{partitions,[]},。如果有空[]is ok。否則我有問題。

我發現使用二郎神例如,從慶典:

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

可以解析rabbitmqctl標準輸出使用erl(或其他工具),並返回信息「空/不爲空」或返回代碼?

我絕對不知道Erlang。

如果有人幫我,我會很高興:-)

+0

您需要刪除輸入的第一行是因爲它不是Erlang項的一部分,在列表的末尾添加一個點'.',商店,到一個文件中,並那麼你可以用['file:consult/1']來閱讀它(http://erldocs.com/current/kernel/file.html?i=0&search=file:consult#consult/1)。其餘的是數據操作。 –

回答

3

您可以使用此API

http://your_ip:15672/api/nodes

在那裏你可以檢查一個節點是向上或向下

name: "[email protected]", 
type: "disc", 
running: false, 
+cluster_links: (0)[...], 

或分區

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

你不需要二郎殼

+0

作爲補充,您可以選擇僅使用以下格式顯示特定信息: 'http:// your_ip:15672/api/nodes?columns = name,running,cluster_links' – midihenry