Skip to content

Instantly share code, notes, and snippets.

@upbit
Last active October 10, 2015 12:05
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 upbit/2b2bfe859fddbc3e2639 to your computer and use it in GitHub Desktop.
Save upbit/2b2bfe859fddbc3e2639 to your computer and use it in GitHub Desktop.
Erlang shell scripts for process
%% message_queue_len
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(message_queue_len,R1,0) > proplists:get_value(message_queue_len,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R -> {true, R} end end,
erlang:processes())), 10).
%% reductions
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(reductions,R1,0) > proplists:get_value(reductions,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R -> {true, R} end end,
erlang:processes())), 10).
%% heap_size
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(heap_size,R1,0) > proplists:get_value(heap_size,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R -> {true, R} end end,
erlang:processes())), 10).
%% Search "seestar_session", and sort by heap_size
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(heap_size,R1,0) > proplists:get_value(heap_size,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R ->
case string:str(lists:flatten(io_lib:format("~s", [term_to_binary(R)])), "seestar_session") of
V when V > 0 -> {true, R}; _ -> false end end end, erlang:processes())), 10).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment