| 1 | -module(beam_stats_processes). |
| 2 | |
| 3 | -include("include/beam_stats_process.hrl"). |
| 4 | -include("include/beam_stats_processes.hrl"). |
| 5 | |
| 6 | -export_type( |
| 7 | [ t/0 |
| 8 | ]). |
| 9 | |
| 10 | -export( |
| 11 | [ collect/0 |
| 12 | ]). |
| 13 | |
| 14 | -define(T, #?MODULE). |
| 15 | |
| 16 | -type t() :: |
| 17 | ?T{}. |
| 18 | |
| 19 | -spec collect() -> |
| 20 | t(). |
| 21 | collect() -> |
| 22 | Ps = [beam_stats_process:of_pid(P) || P <- erlang:processes()], |
| 23 | ?T |
| 24 | { individual_stats |
| 25 | = Ps |
| 26 | , count_all |
| 27 | = length(Ps) |
| 28 | , count_exiting |
| 29 | = length([P || P <- Ps, P#beam_stats_process.status =:= exiting]) |
| 30 | , count_garbage_collecting |
| 31 | = length([P || P <- Ps, P#beam_stats_process.status =:= garbage_collecting]) |
| 32 | , count_registered |
| 33 | = length(registered()) |
| 34 | , count_runnable |
| 35 | = length([P || P <- Ps, P#beam_stats_process.status =:= runnable]) |
| 36 | , count_running |
| 37 | = length([P || P <- Ps, P#beam_stats_process.status =:= running]) |
| 38 | , count_suspended |
| 39 | = length([P || P <- Ps, P#beam_stats_process.status =:= suspended]) |
| 40 | , count_waiting |
| 41 | = length([P || P <- Ps, P#beam_stats_process.status =:= waiting]) |
| 42 | }. |