Forced erl_crash.dump

Mats Cronqvist mats.cronqvist@REDACTED
Tue Aug 15 12:02:16 CEST 2006


Heinrich Venter wrote:
> Hi all
> 
> Is there a way to force a running node to write a erl_crash.dump without
> actually killing the node?
> I am trying to figuire out what processes are running in a live node.
> Any suggestions how best to do this?


   assuming by "running" you mean which processes are using reductions, and that 
you're working in the shell, this should work;

define some trivial funs;
PI = fun(P,T)-> try element(2,process_info(P,T)) catch _:_ -> [] end end.
I = fun()-> [{P,PI(P,reductions)} || P <- processes()] end.
F = fun(G,[_X,_X|T],O) -> G(G,T,O); (G,[{P,R1},{P,R2}|T],O) -> 
G(G,T,[{R2-R1,P,PI(P,initial_call),PI(P,registered_name)}|O]);(_,[],O) -> 
lists:sublist(lists:reverse(lists:sort(O)),20); (G,[_|T],O) -> G(G,T,O) end.
GO = fun(T) -> X=I(), timer:sleep(T), F(F,lists:merge(X,I()),[]) end.

   run
GO(1000).
[{1450,<0.216.0>,{proc_lib,init_p,5},cpu_sup},
  {1072,<0.60.0>,{net_kernel,spawn_func,6},prfTarg},
  {238,<0.61.0>,{erlang,apply,2},[]},
  {56,<0.577.0>,{inet_tcp_dist,do_accept,6},[]},
  {50,<0.47.0>,{inet_tcp_dist,do_accept,6},[]},
  {20,<0.22.0>,{proc_lib,init_p,5},net_kernel},
  {13,<0.214.0>,{proc_lib,init_p,5},memsup},
  {6,<0.24.0>,{net_kernel,ticker,2},[]}]

the arg of GO/1 is the tick in ms.
output is a list of {RedsLastTick,Pid,InitialCall,RegisteredName}.

if your system has many thousands of processes, don't try this:>

   mats



More information about the erlang-questions mailing list