Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Linux top CPU utilisation output [closed]

I'm using an single core small ARM processor running under Debian and have problems understanding the CPU utilisation output of top, see:

top - 15:31:54 up 30 days, 23:00,  2 users,  load average: 0.90, 0.89, 0.87
Tasks:  44 total,   1 running,  43 sleeping,   0 stopped,   0 zombie
Cpu(s): 65.0%us, 20.3%sy,  0.0%ni, 14.5%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:     61540k total,    40056k used,    21484k free,        0k buffers
Swap:        0k total,        0k used,        0k free,    22260k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                    
26028 root      20   0  2536 1124  912 R  1.9  1.8   0:00.30 top                                                                                        
31231 root      19  -1 45260  964  556 S  1.9  1.6   1206:15 owserver                                                                                   
    3 root      15  -5     0    0    0 S  0.3  0.0   0:08.68 ksoftirqd/0                                                                                
  694 root      20   0 28640  840  412 S  0.3  1.4 468:26.74 rsyslogd         

The column %CPU is very low over all processes, in this example it is all together 4,4% (all other process below had been on 0%) But the allover CPU on line 3 shows 65%us and 20%sy, so for both a very high value - and by the way, this is how the system feels: very slow :-( The system is almost always in this condition: very low CPU for all processes, but high user+system CPU. Can anybody explain why there is such a high inconsistence within the top tool output? And what tool can I use to better find out what causes the high user+system CPU utilization - top seems to be useless here.

update: meanwhile I've found this thread here, which discusses a similiar question, but I can't verify what is written there:

  • The command uptime shows the average CPU utilization per 1/5/15 minutes
  • This is close to what the first line of top outputs as sum of %us+%sy. But this is changing much more, maybe it is an average per 10s?
  • Even if looking longer time on the top output, the sum of %us+%sy is always several times higher than the summary of all %CPU

Thanks Achim

like image 776
Achim Avatar asked Dec 09 '12 01:12

Achim


People also ask

Why does the output of the top command show more than 100% CPU utilization for a process?

If you have 8 cores, then top can display CPU usage from 0% (idle system) to 800% (full power). Your program is just using your 4 cores with hyper-threading (so 8 virtual cores) at maximum capacity. So top gives you nearly 8 x 100% = 800%.

How do you read the top CPU usage?

Check CPU usage with top command in Linux The best way to check cpu usage in Linux is using top command. Simply type “top” at the command prompt. You will then see a list of the processes that are currently running, as well as information about the CPU usage, memory usage, and load average.

How do you read atop output?

Reading atop reports and logsOnce you open a log file (e.g., atop -r /var/log/atop/atop_20140813 ), then use t to go forward in 10-minute intervals, and T to go back. You can analyze specific times by pressing b and then entering the time. The above shortcut keys also work in this mode: a , c , d , m , and n .


1 Answers

You should read the manpage of top to understand its output more astutely. From the manpage:

%CPU -- CPU usage

The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. The default screen update time is 3 seconds, which can be changed with #top -d ss.tt. To measure commulative CPU usage, run top -S.

-S : Cumulative time mode toggle

Starts top with the last remembered 'S' state reversed. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children have used.

The CPU states are shown in the Summary Area. They are always shown as a percentage and are for the time between now and the last refresh.

    us  --  User CPU time
      The time the CPU has spent running users' processes that are not niced.

    sy  --  System CPU time
      The time the CPU has spent running the kernel and its processes.

    ni  --  Nice CPU time
      The time the CPU has spent running users' proccess that have been niced.

    wa  --  iowait
      Amount of time the CPU has been waiting for I/O to complete.

    hi  --  Hardware IRQ
      The amount of time the CPU has been servicing hardware interrupts.

    si  --  Software Interrupts
      The amount of time the CPU has been servicing software interrupts.

    st  --  Steal Time
      The amount of CPU 'stolen' from this virtual machine by the hypervisor for other tasks (such as running another virtual machine).

Under normal circumstances %us+%sy should always be higher.

like image 70
manav m-n Avatar answered Oct 27 '22 03:10

manav m-n