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
Tasks: 311 total, 17 running, 294 sleeping, 0 stopped, 0 zombie
Cpu(s): 9.7%us, 9.1%sy, 0.0%ni, 47.5%id, 0.7%wa, 1.2%hi, 31.7%si, 0.0%st
Mem: 33012208k total, 3576120k used, 29436088k free, 31988k buffers
Swap: 0k total, 0k used, 0k free, 485704k cached
There are 8 CPUs/Cores so total CPU percentage would be 100x8 = 800%.
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
44367 root 19 -1 2720 844 728 R 48.4 0.0 0:02.05 myscript
44365 root 19 -1 2720 848 728 R 46.9 0.0 0:02.35 myscript
44448 root 19 -1 2720 844 728 R 43.9 0.0 0:01.78 myscript
44665 root 19 -1 2720 844 728 R 43.9 0.0 0:00.96 myscript
44772 root 19 -1 2720 848 728 R 43.9 0.0 0:00.29 myscript
54460 mrme 19 -1 1587m 54m 2992 R 36.3 0.2 7:51.67 myscript
54462 mrme 19 -1 1586m 53m 2992 R 34.8 0.2 7:15.12 myscript
54463 mrme 19 -1 1587m 54m 2992 R 34.8 0.2 7:58.44 myscript
54461 mrme 19 -1 1586m 54m 2992 R 33.3 0.2 7:26.50 myscript
54464 mrme 19 -1 1587m 54m 2992 R 31.8 0.2 7:37.07 myscript
54465 mrme 19 -1 1587m 54m 2992 S 31.8 0.2 7:24.34 myscript
54466 mrme 19 -1 1587m 54m 2992 R 31.8 0.2 7:40.44 myscript
54459 mrme 19 -1 1588m 55m 3036 R 30.2 0.2 7:10.97 myscript
3342 root 18 -2 34596 18m 1872 S 27.2 0.1 0:39.38 myscript
4332 root 18 -2 40252 19m 1956 S 13.6 0.1 2:12.55 myscript
44760 root 20 0 19132 1300 824 R 7.6 0.0 0:00.13 top -c -b -n 1
54458 root 19 -1 34184 19m 1560 S 6.0 0.1 0:45.39 monitor.pl
25 root 15 -5 0 0 0 S 3.0 0.0 0:06.60 [ksoftirqd/7]
54455 root 19 -1 1599m 54m 2844 S 3.0 0.2 0:10.42 myscript
16 root 15 -5 0 0 0 S 1.5 0.0 0:10.23 [ksoftirqd/4]
4716 root 19 -1 161m 101m 74m S 1.5 0.3 0:03.74 script2.sh
1 root 20 0 10320 672 572 S 0.0 0.0 0:41.31 init [3]
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.