-1

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

1
  • It's not clear whether you're interested in the system's total cpu usage, or specifically that of your "app". If it's a specific program you're interested in, you might do better using "ps" on its pid. It's not unlikely that something cpu-heavy is occasionally active for a short time, leading to your occasional zero results for idle. What else is running on your system? Some further general details about your system might be useful. (Please add any further details to your original question, rather than as comments.)
    – jeffas
    Commented Jun 12 at 9:14

0

You must log in to answer this question.

Browse other questions tagged .