Create a gist now

Instantly share code, notes, and snippets.

I'm sure everybody's written ten of these...
-module(ns_ps).
-export([nps/0, nps/1, ps/0, ps/1]).
interestingThings() ->
[current_function, initial_call, message_queue_len,
total_heap_size, heap_size, stack_size, reductions].
defaultOutput(S) -> io:format("~s~n", [S]).
ps(Output) ->
InterestingParts = interestingThings(),
lists:foreach(fun (Proc) ->
try
Info = process_info(Proc),
Output([string:join(
[atom_to_list(node())|
lists:map(fun (X) ->
io_lib:format("~p",
[proplists:get_value(X, Info)])
end,
InterestingParts)],
"\t"
)])
catch _:_ -> ok
end
end,
processes()).
ps() -> ps(fun defaultOutput/1).
nps(Output) ->
InterestingParts = interestingThings(),
Output(string:join(lists:map(fun erlang:atom_to_list/1, [node|InterestingParts]), ",")),
lists:foreach(
fun(Node) -> rpc:call(Node, ?MODULE, ps, [Output]) end,
nodes(known)).
nps() -> nps(fun defaultOutput/1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment