如何解析rabbitmq的状态输出?[英] How to parse rabbitmq status output?

本文是小编为大家收集整理的关于如何解析rabbitmq的状态输出?的处理方法,想解了如何解析rabbitmq的状态输出?的问题怎么解决?如何解析rabbitmq的状态输出?问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我在 Linux 上安装了 RabbitMQ,它是一款很棒的软件.

当我运行这个命令时:

sudo rabbitmqctl status

我得到一团糟的输出:

[{pid,18665},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.1.5"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.1.5"},
      {webmachine,"webmachine","1.10.3-rmq3.1.5-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.1.5-git680dba8"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.1.5"},
      {rabbit,"RabbitMQ","3.1.5"},
      {os_mon,"CPO  CXC 138 46","2.2.7"},
      {inets,"INETS  CXC 138 49","5.7.1"},
      {xmerl,"XML parser","1.2.10"},
      {mnesia,"MNESIA  CXC 138 12","4.5"},
      {amqp_client,"RabbitMQ AMQP Client","3.1.5"},
      {sasl,"SASL  CXC 138 11","2.1.10"},
      {stdlib,"ERTS  CXC 138 10","1.17.5"},
      {kernel,"ERTS  CXC 138 10","2.14.5"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:30] [kernel-poll:true]\n"},
 {memory,
     [{total,179426464},
      {connection_procs,300224},
      {queue_procs,14434024},
      {plugins,474968},
      {other_proc,9607952},
      {mnesia,89264},
      {mgmt_db,1539936},
      {msg_index,85175152},
      {other_ets,29060560},
      {binary,18243208},
      {code,17504466},
      {atom,1602617},
      {other_system,1394093}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1522479923},
 {disk_free_limit,1000000000},
 {disk_free,58396659712},
 {file_descriptors,
     [{total_limit,924},{total_used,17},{sockets_limit,829},{sockets_used,4}]},
 {processes,[{limit,1048576},{used,233}]},
 {run_queue,0},
 {uptime,5169640}]

它看起来像 JSON,但实际上不是.

这是什么数据格式?你是怎么发现的?

我能找到的最接近的是:http://erlang.org/doc/man/yecc.html

推荐答案

rabbitmqctl 有一个 --formatter 标志来请求可选的 JSON 格式输出.例如:

sudo rabbitmqctl status --formatter json | jq .disk_free_limit
50000000

本文地址:https://www.itbaoku.cn/post/1794085.html