Created
August 7, 2012 19:14
-
-
Save gmr/3288520 to your computer and use it in GitHub Desktop.
Get the current runtime state of a RabbitMQ node from the cli in erlang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% -*- erlang -*- | |
main(_) -> | |
net_kernel:start([procount, shortnames]), | |
{_, Hostname} = inet:gethostname(), | |
Remote = lists:concat(["rabbit@", Hostname]), | |
io:format("status report ~s~n", [Remote]), | |
Node = erlang:list_to_atom(Remote), | |
MemEts = rpc:call(Node, erlang, memory, [ets]), | |
MemBinary = rpc:call(Node, erlang, memory, [binary]), | |
MemProc = rpc:call(Node, erlang, memory, [processes]), | |
MemProcUsed = rpc:call(Node, erlang, memory, [processes_used]), | |
MemAtom = rpc:call(Node, erlang, memory, [atom]), | |
MemAtomUsed = rpc:call(Node, erlang, memory, [atom_used]), | |
MemCode = rpc:call(Node, erlang, memory, [code]), | |
MemUsed = rpc:call(Node, erlang, memory, [total]), | |
MemLimit = rpc:call(Node, vm_memory_monitor, get_memory_limit, []), | |
ProcUsed = rpc:call(Node, erlang, system_info, [process_count]), | |
ProcTotal = rpc:call(Node, erlang, system_info, [process_limit]), | |
RunQueue = rpc:call(Node, erlang, statistics, [run_queue]), | |
{{_,BytesIn},{_,BytesOut}} = rpc:call(Node, erlang, statistics, [io]), | |
{ContextSwitches, _} = rpc:call(Node, erlang, statistics, [context_switches]), | |
io:format("mem_ets: ~w~nmem_binary: ~w~nmem_proc: ~w~nmem_proc_used: ~w~nmem_atom: ~w~nmem_atom_used: ~w~nmem_code: ~w~nmem_used: ~w~nmem_limit: ~w~n", | |
[MemEts, MemBinary, MemProc, MemProcUsed, MemAtom, MemAtomUsed, MemCode, MemUsed, MemLimit]), | |
io:format("proc_used: ~w~nproc_limit: ~w~n", [ProcUsed, ProcTotal]), | |
io:format("bytes_in: ~w~nbytes_out: ~w~n", [BytesIn, BytesOut]), | |
io:format("run_queue: ~w~ncontext_switches: ~w~n", [RunQueue, ContextSwitches]). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment