了解Linux顶级CPU利用率输出

时间:2012-12-09 01:15:34

标签: 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         

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

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

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

由于    Achim的

1 个答案:

答案 0 :(得分:6)

您应该阅读manpage top以更明确地了解其输出。从联机帮助页:

  

%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).

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

相关问题