Detect process eating cpu without: top, htop, ps

cpuprocess

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?

PS.: linking about wait time,
linking about load average

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:

  1. The process may consist of several threads and top may not sum them up. You can see the number of threads by this:

    ps -eo pid,nlwp,%cpu,user,args
    

    In top you can switch the thread handling with H. The CPU usage of each thread is usually quite low.

  2. 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 in top. It does not tell you which processes cause it to which extent but if the value is low then it cannot explain the effect.

Related Question