dig*_*ity 6 linux process monitoring debian ps
我使用 Ubuntu 12.04.1 Linux。我看到了一个进程的命令%CPU和C输出格式之间的区别ps。ps手册页中没有明确指出。
手册页说:
CODE HEADER DESCRIPTION
%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).
c C processor utilization. Currently, this is the integer
value of the percent usage over the lifetime of the
process. (see %cpu).
Run Code Online (Sandbox Code Playgroud)
所以基本上它应该是一样的,但它不是:
$ ps aux | head -1
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
$ ps aux | grep 32473
user 32473 151 38.4 18338028 6305416 ? Sl Feb21 28289:48 ZServer -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./log
$ ps -ef | head -1
UID PID PPID C STIME TTY TIME CMD
$ ps -ef | grep 32473
user 32473 32472 99 Feb21 ? 19-15:29:50 ZServer -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./log
Run Code Online (Sandbox Code Playgroud)
顶部同时显示 2% 的 CPU 利用率。我知道“顶部”显示当前 CPU 利用率,同时ps显示进程生命周期内的 CPU 利用率。
我猜这两种格式选项的生命周期定义有些不同。
小智 3
%cpu和列显示的内容C几乎相同,但不完全相同。如果您查看psin的源代码,您可以看到和ps/output.c之间的区别pr_cpr_cpu
C%cpu是您可以猜到的整数值。奇怪的区别是C被限制为最大值 99 而%cpu不是(有一个检查%cpu,但它只是将格式从 更改xx.x%为xxx%)。
现在,我不太确定为什么C会有这种夹紧;似乎有点武断。它从 procps 3.2.7 (2006) 就已经存在了,所以它可能来自单 CPU 时代
| 归档时间: |
|
| 查看次数: |
15688 次 |
| 最近记录: |