Created
November 14, 2013 00:38
-
-
Save bsparrow435/7459225 to your computer and use it in GitHub Desktop.
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
-module(heap_query). | |
-compile(export_all). | |
main([NodeName0, Cookie]) -> | |
Name = '[email protected]', | |
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