I've been using a script to create a log based from information i can get in top and then report when my app is using too much resources, to retrieve the cpu usage i take the entire line
%Cpu(s): 13.6 us, 1.3 sy, 0.0 ni, 82.7 id, 0.0 wa, 0.0 hi, 2.4 si, 0.0 st
and then with code i take the corresponding percentage of idle (and then substracting the value to 100.0), but there's a lot of moments where idle is in 0.0, am i using the correct aproach to measure when my cpu is stressed? i think is weird to have idle a lot in 0.0.
This is the command top -n 1 -b
where i take the output from, maybe im missing somenthing related to multithreads or cores ?
EDIT: To be more clear, im interested in seeing the system's total cpu usage, my script also reports the most resource consumming processes (such as cron tasks, sidekiq, puma, nginx, ruby or scripts) but there's no consistency from where i can take useful information because i get 100% a lot, that's why i feel like maybe using idle its not the correct aproach