PROC文件中stat统计信息

翻译文件Documentation/filesystems/proc.txt的1.8节,关于/proc/stat文件内容的描述:

 

1.8 位于/proc/stat文件中的内核杂项统计
-------------------------------------------------

内核在文件/proc/stat中保存了有关自身活动的各种信息。所有的统计数字都是自系统启动后累加起来的。使用cat命令简单的查看下文件:

  > cat /proc/stat
  cpu  2255 34 2290 22625563 6290 127 456 0 0 0
  cpu0 1132 34 1441 11311718 3675 127 438 0 0 0
  cpu1 1123 0 849 11313845 2614 0 18 0 0 0
  intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
  ctxt 1990473
  btime 1062191376
  processes 2915
  procs_running 1
  procs_blocked 0
  softirq 183433 0 21755 12 39 1137 231 21459 2263

以cpu开头的第一行统计数字为之后行cpu统计值的总和。这些数字值标识cpu处理器不同类型的事务耗费的时间总和。单位为USER_HZ(典型值为100)。以下按照从左到右的顺序说明每一列数字的含义。

- user: 用户态正常进程执行时间

- nice: 用户态nice值为负的进程执行时间

- system: 进程在内核态的执行时间

- idle: 空闲时间

- iowait: 简单来说,iowait代表着等待I/O操作完成的时间。但是还有几个问题:
  1. 处理器不会一直等待I/O操作完成,iowait是任务等待I/O完成的时间。当有任务的I/O操作未完成时处理器进入空闲状态,其它的任务将调度到此处理器执行。
  2. 在多核处理器上,等待I/O操作完成的任务不在任何CPU上运行,所以每个CPU的iowait时间很难统计。
  3. PROC文件stat中的iowait值在一定情况下还会减少。
  所以,文件stat中的iowait值并不准确。

- irq: 硬件中断的执行时间

- softirq: 软中断的执行时间

- steal: 非自主等待时间

- guest: 运行正常客户机的时间

- guest_nice: 运行niced客户机的时间

 

"intr"行显示了自启动以来服务的每种系统中断的总和。第一列是所有中断的总数包括没有中断号的体系结构特殊中断;以后的每一列显示一个特定具有中断号的中断总数。无中断号的中断未单独显示,包括在了第一列的总数中。

"ctxt"行显示在所有CPU直接上下文切换的总数。

"btime"含显示系统启动的时间,其值为自1970年1月1日00:00.00后的秒数。

"processes"行显示创建的进程和线程的总数,包括但不限于由fork和clone系统调用创建的。

"procs_running"行显示在运行或者就绪状态的线程总数(例如,可运行线程的总数)。

"procs_blocked"行显示处于阻塞状态等待I/O完成的进程总数。

"softirq"行显示自系统启动以来,服务的所有软中断的总数。第一列为所有软中断的总数,之后的每一列为某一特定软中断的总数。

 

英文原文:

 

1.8 Miscellaneous kernel statistics in /proc/stat

-------------------------------------------------

Various pieces   of  information about  kernel activity  are  available in the /proc/stat file.  All  of  the numbers reported  in  this file are  aggregates since the system first booted.  For a quick look, simply cat the file:

  > cat /proc/stat
  cpu  2255 34 2290 22625563 6290 127 456 0 0 0
  cpu0 1132 34 1441 11311718 3675 127 438 0 0 0
  cpu1 1123 0 849 11313845 2614 0 18 0 0 0
  intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
  ctxt 1990473
  btime 1062191376
  processes 2915
  procs_running 1
  procs_blocked 0
  softirq 183433 0 21755 12 39 1137 231 21459 2263

The very first  "cpu" line aggregates the  numbers in all  of the other "cpuN" lines.  These numbers identify the amount of time the CPU has spent performing different kinds of work.  Time units are in USER_HZ (typically hundredths of a second).  The meanings of the columns are as follows, from left to right:

- user: normal processes executing in user mode
- nice: niced processes executing in user mode
- system: processes executing in kernel mode
- idle: twiddling thumbs
- iowait: In a word, iowait stands for waiting for I/O to complete. But there are several problems:
  1. Cpu will not wait for I/O to complete, iowait is the time that a task is waiting for I/O to complete. When cpu goes into idle state for outstanding task io, another task will be scheduled on this CPU.
  2. In a multi-core CPU, the task waiting for I/O to complete is not running on any CPU, so the iowait of each CPU is difficult to calculate.
  3. The value of iowait field in /proc/stat will decrease in certain conditions.
  So, the iowait is not reliable by reading from /proc/stat.

- irq: servicing interrupts
- softirq: servicing softirqs
- steal: involuntary wait
- guest: running a normal guest
- guest_nice: running a niced guest

The "intr" line gives counts of interrupts  serviced since boot time, for each of the  possible system interrupts.   The first  column  is the  total of  all interrupts serviced  including  unnumbered  architecture specific  interrupts; each  subsequent column is the  total for that particular numbered interrupt. Unnumbered interrupts are not shown, only summed into the total.

The "ctxt" line gives the total number of context switches across all CPUs.

The "btime" line gives  the time at which the  system booted, in seconds since the Unix epoch.

The "processes" line gives the number  of processes and threads created, which includes (but  is not limited  to) those  created by  calls to the  fork() and clone() system calls.

The "procs_running" line gives the total number of threads that are running or ready to run (i.e., the total number of runnable threads).

The   "procs_blocked" line gives  the  number of  processes currently blocked, waiting for I/O to complete.


The "softirq" line gives counts of softirqs serviced since boot time, for each of the possible system softirqs. The first column is the total of all softirqs serviced; each subsequent column is the total for that particular softirq.

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值