I went thru a problem where I could only guess what process was eating the cpu.
My cpu usage was about 80% for all cores at psensor.
I tried htop
, top
and ps -A -o pcpu,pid,cmd --sort +pcpu
(the last one I even tried with sudo to no avail).
All these shown the culprit pid (that I was aware of) using about 7% only…
When I SIGKILL on that pid, all get back to normal.
To test, I did an infinite loop on terminal while true;do echo -n;done
but that I could clearly see at htop; so my guess what was causing trouble was not similar to that…
So I wonder if there are other ways I could have found the culprit without having to guess?
Thinking again, I think I would like to know what calculations psensor
and "system load indicator applet" uses that was able to show that value but the others were unable to?
Best Answer
I am not familiar enough with the details to give precise hints but I guess there are two sources of differences between the real caused load and the shown CPU usage:
The process may consist of several threads and
top
may not sum them up. You can see the number of threads by this:In
top
you can switch the thread handling withH
. The CPU usage of each thread is usually quite low.The process may cause a lot of I/O. I/O wait time is part of the overall CPU load but may not be part of a process's CPU usage value. So check the
wait
value intop
. It does not tell you which processes cause it to which extent but if the value is low then it cannot explain the effect.