CPU usage by processes using top command
Guys,
I'm new here so forgive my ignorance if I'm missing something here. Wonder if someone can help me here, or point me to the right rtfm :-) I'm using top command to determine total cpu utilization by applications. If you look at below top output, you can see CPU is 52.4% utilized. i.e. 9.7 + 9.1 + 0.7 + 1.2 + 31.7 = 52.4% and including the idle (47.5 + 52.4 = 99.9%) would give you the total CPU - still not sure why 0.1 is missing ;) Code:
top - 20:39:33 up 28 min, 1 user, load average: 12.38, 10.38, 6.31 Now I have a custom script that's keeping the CPUs busy Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND If I sum up the CPU usage for all the processes (myscript) that would be: 48.4 + 46.9 + 43.9 + 43.9 + 43.9 + 36.3 + 34.8 + 34.8 + 33.3 + 31.8 + 31.8 + 31.8 + 30.2 + 27.2 + 13.6 + 7.6 + 6.0 + 3.0 + 3.0 + 1.5 + 1.5 = 555.2% That means that the processes are using 555.2% of 800% CPU (correct me if I'm doing it wrong) In another words, it's 69.4% of the total CPU usage. But top's top shows that total CPU utilization is 52.4% why is there a difference of 17%? Which one should I trust, the total top calculated value or the total average processes usage? which one is accurate? I'm not saying that the top is buggy, but I'm sure there's something I'm missing, whether it's the top refresh cycle or something else I need to know? Would greatly appreciate your help. |
Welcome to the vagaries of sampling monitors.
Let's start at the beginning - how (exactly) did you produce that top listing. |
Actually this was taken from a production box, and the 'command' column had the actual long&ugly commands, so I had to just rename it 'myscript'.
The box is handling thousands of connections per second, 'myscript' is handling those connections (http), the output is the result of 'top -c -b -n 1' My point here is why does the total sum of the CPU usage of all the processes greater than the actual CPU utilization as shown in top header. Thanks |
I would suggest you (re-)read the manpage - particularly the bit in "BUGS". Then you will understand why I asked.
|
All times are GMT -5. The time now is 05:30 AM. |