【问题标题】:why ps aux shows big different cpu usage with top为什么 ps aux 与 top 显示出很大不同的 cpu 使用率
【发布时间】:2013-12-20 06:35:59
【问题描述】:

Linux 服务器是这样的: Linux hostname 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

并且ps aux 显示不正确的 CPU 使用率并且该值不合理。该值不会像top那样频繁更新。

例如,对于同一个进程,ps 显示 cpu 使用率为 210.0,keep 显示该值在多次执行中。但在另一个终端中,top 显示杯子使用量在 1xx 到 2xx 之间不断变化。顶部的价值是合理的。知道为什么 ps aux 不能正常工作吗?

【问题讨论】:

    标签: linux cpu-usage ps


    【解决方案1】:

    两者都应该工作,但它们的工作方式不同:

    来自ps的MAN:

    %cpu       %CPU     cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been
                        running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. (alias pcpu).
    

    和顶部

      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 envi-
              ronment, 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.
    

    【讨论】:

      猜你喜欢
      • 2013-12-27
      • 1970-01-01
      • 2022-12-05
      • 2013-02-12
      • 2020-12-12
      • 2011-03-04
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多