了解Linux顶级CPU利用率输出

Ach*_*him 8 linux performance

我正在使用在Debian下运行的单核小型ARM处理器,并且在理解top的CPU利用率输出时遇到问题,请参阅:

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         
Run Code Online (Sandbox Code Playgroud)

列%CPU在所有进程中都非常低,在本例中它们总共为4,4%(下面的所有其他进程都是0%)但是第3行的通用CPU显示65%us和20%sy,所以对于非常高的价值 - 顺便说一句,这就是系统的感觉:非常慢:-(系统几乎总是处于这种状态:所有进程的CPU都很低,但是高用户+系统CPU.任何人都可以解释为什么在顶级工具输出中存在如此高的不一致性?我可以使用什么工具来更好地找出导致高用户+系统CPU利用率的原因 - 顶部似乎在这里没用.

更新:同时我在这里找到了这个帖子,它讨论了一个类似的问题,但是我无法验证那里写的是什么:

  • 命令正常运行时间显示每1/5/15分钟的平均CPU利用率
  • 这接近于最高输出的第一行作为%us +%sy的总和.但这种情况正在发生变化,也许是每10年的平均值?
  • 即使在最高输出上查看较长时间,%us +%sy的总和也总是比所有%CPU的总和高几倍

谢谢Achim

man*_*m-n 6

你应该阅读manpagetop更敏锐地了解它的输出.从联机帮助页:

%CPU - CPU使用率

任务在上次屏幕更新后经过的CPU时间的份额,表示为总CPU时间的百分比.默认屏幕更新时间为3秒,可以使用更改#top -d ss.tt.要测量通信CPU使用情况,请运行top -S.

-S:累积时间模式切换

从最后记住的'S'状态开始逆转.当"累积模式"为"开启"时,每个进程都会列出它和它的死孩子使用的CPU时间.

CPU状态显示在摘要区域中.它们始终显示为百分比,表示从现在到最后一次刷新之间的时间.

    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).
Run Code Online (Sandbox Code Playgroud)

在正常情况下,%us +%sy应始终更高.