关于procps top 显示CPU占用率

1 背景

之前不清楚它的含义,以为系统有问题。

procps版本的top,%CPU列的值会给人造成误解,各task的CPU和 大于 顶部的us+sy。

2 top默认显示

显示如下:       

top.t - 04:03:33 up  4:03,  2 users,  load average: 1.34, 0.52, 0.38
Tasks:  47 total,   3 running,  44 sleeping,   0 stopped,   0 zombie
Cpu(s): <strong><span style="color:#ff0000;">65.0%us, 35.0%sy</span></strong>,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    710736k total,    17056k used,   693680k free,        0k buffers
Swap:        0k total,        0k used,        0k free,     4692k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                  
 1159 root      20   0  1608  376  320 R  <span style="color:#ff0000;"><strong>100</strong>  </span>0.1   0:08.77 dhry_test                                
 1160 root      20   0  1608  376  320 R   <span style="color:#ff0000;"><strong>99</strong>  </span>0.1   0:08.00 dhry_test                                
    1 root      20   0  2992  652  584 S    0  0.1   0:03.35 init            

   
其中100 + 99 超过了总的CPU使用率。

3 原由

在top 的man中解释:
       k: %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.  In a true
          SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage  will  be  divided  by  the
          total number of CPUs.  You toggle 'Irix/Solaris' modes with the 'I' interactive command.
默认是Irix mode,即显示的是总的CPU时间。
可以输入 'I'  来关闭Irix mode模式,这样看起来就比较容易理解。

4 关闭Irix mode后的显示

top.t - 04:12:57 up  4:12,  2 users,  load average: 0.16, 0.23, 0.34
Tasks:  47 total,   3 running,  44 sleeping,   0 stopped,   0 zombie
Cpu(s): 64.8%us, 35.2%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    710736k total,    17064k used,   693672k free,        0k buffers
Swap:        0k total,        0k used,        0k free,     4692k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                  
 1163 root      20   0  1608  376  320 R <strong><span style="color:#ff0000;">50.2</span></strong>  0.1   0:08.03 dhry_test                                
 1164 root      20   0  1608  376  320 R <span style="color:#ff0000;"><strong>49.9</strong></span>  0.1   0:07.18 dhry_test  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值