1 -module(beam_stats_processes).
3 -include("include/beam_stats_process.hrl").
4 -include("include/beam_stats_processes.hrl").
24 Pids = beam_stats_source:erlang_processes(),
25 PsOpts = [beam_stats_process:of_pid(P) || P <- Pids],
26 Ps = [P || {some, P} <- PsOpts],
33 = length([P || P <- Ps, P#beam_stats_process.status =:= exiting])
34 , count_garbage_collecting
35 = length([P || P <- Ps, P#beam_stats_process.status =:= garbage_collecting])
37 = length(beam_stats_source:erlang_registered())
39 = length([P || P <- Ps, P#beam_stats_process.status =:= runnable])
41 = length([P || P <- Ps, P#beam_stats_process.status =:= running])
43 = length([P || P <- Ps, P#beam_stats_process.status =:= suspended])
45 = length([P || P <- Ps, P#beam_stats_process.status =:= waiting])
48 collect_and_print() ->
55 { individual_stats = PerProcessStats
56 , count_all = CountAll
57 , count_exiting = CountExiting
58 , count_garbage_collecting = CountGarbageCollecting
59 , count_registered = CountRegistered
60 , count_runnable = CountRunnable
61 , count_running = CountRunning
62 , count_suspended = CountSuspended
63 , count_waiting = CountWaiting
66 PerProcessStatsSorted = lists:sort(
67 fun (#beam_stats_process{memory=A}, #beam_stats_process{memory=B}) ->
68 % From lowest to highest:
73 lists:foreach(fun beam_stats_process:print/1, PerProcessStatsSorted),
74 io:format("==================================================~n"),
78 "CountGarbageCollecting : ~b~n"
79 "CountRegistered : ~b~n"
80 "CountRunnable : ~b~n"
82 "CountSuspended : ~b~n"
87 , CountGarbageCollecting