Skip to content

Instantly share code, notes, and snippets.

@bsparrow435
Created November 14, 2013 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsparrow435/7459225 to your computer and use it in GitHub Desktop.
Save bsparrow435/7459225 to your computer and use it in GitHub Desktop.
-module(heap_query).
-compile(export_all).
main([NodeName0, Cookie]) ->
Name = 'heap_query@127.0.0.1',
NodeName = list_to_atom(NodeName0),
case net_kernel:start([Name]) of
{ok, _} ->
erlang:set_cookie(node(), list_to_atom(Cookie)),
case net_kernel:hidden_connect_node(NodeName) of
true ->
F = fun() ->
proplists:get_value(total_heap_size,process_info(whereis(bitcask_merge_worker)))
end,
TotalHeap = rpc:call(NodeName,erlang,apply,[F,[]]),
TS = {_,_,_Micro} = os:timestamp(),
io:format("{Time,Size}: ~p~n", [{calendar:now_to_universal_time(TS),TotalHeap}]),
ok;
false ->
io:format("Could not connect to ~s with cookie ~s", [NodeName, Cookie]);
_ ->
io:format("net_kernel:connect/1 reports ~s is not alive", [Name])
end;
{error, Reason} ->
io:format("Could not connect node: ~w~n", [Reason])
end;
main(_) ->
io:format("Usage: riak escript heap_query NODENAME COOKIE").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment