Search code examples
rabbitmqdata-formatsrabbitmqctl

How to parse rabbitmq status output?


I installed RabbitMQ on Linux, it's a great piece of software.

When I run this command:

sudo rabbitmqctl status

I get a mess of output:

[{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}]

It looks like JSON, but it's not.

What data format is this? And how did you find out?

Closest thing I can find is this: http://erlang.org/doc/man/yecc.html


Solution

  • rabbitmqctl has a --formatter flag to request JSON formatted output optionally available. For instance:

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