Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4238949
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: LINUX

2011-12-13 15:07:42

本文是根据 kerneltravel proc文件系统探索系列
学习,具体实际操作的记录
======================================================
1./proc/stat
文件包含了系统启动后的一些系统统计信息
  1. root@ywx:/proc# cat stat
  2. cpu 176639 135540 280464 1528047 10464 0 309 0 0 0 CPU负载信息的总和
  3. cpu0 176639 135540 280464 1528047 10464 0 309 0 0 0
  4. intr 2742253 114 13768 0 1 15432 0 3 0 0 0 0 0 190179 0 0 99432 46446 21084 0 1877 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  5. ctxt 42352114
  6. btime 1323734440
  7. processes 5960
  8. procs_running 1
  9. procs_blocked 0
  10. softirq 1803255 0 1546312 5046 979 30765 0 17728 0 724 201701
上面是我机子上的文件内容
第一行的CPU是你所有CPU负载信息的总和。后面的CPUn(n是数字)表示你那个CPU的信息,我这里只有一个CPU,所以是CPU0,也就是说我的前两行信息相同。
其中的每个数字代表一个相关信息,可以用如下数据结构表示:
  1. struct cpu_info
  2. {
  3. U64 user;
  4. U64 system;
  5. U64 nice;
  6. U64 idle;
  7. U64 iowait;
  8. U64 irq;
  9. U64 softirq;
  10. };
user:从系统启动开始累计到当前时刻,用户态的CPU时间(单位:jiffies),不包       含nice值为负进程。 1jiffies=0.01秒
nice:从系统启动开始累计到当前时刻,nice值为负的进程所占用的时间(单位:       jiffies)
system:从系统启动开始累计到当前时间,核心时间 单位:jiffies
idle: 从系统启动开始累计到当前时刻,除硬盘IO等待时间以外其他等待时间 jiffies
iowait:从系统启动开始累计到当前时刻,硬盘IO等待时间 单位 jiffies
irq:  从系统启动开始累计到当前时刻,硬中断时间  单位 jiffies
softirq: 从系统启动开始累计到当前时刻,软中断时间 单位 jiffies
从2.6.11加了第8列stealstolen time:which is the time spent in other operating systems when running in a virtualized environment
从 2.6.24加了第9列 guest: which is the time spent running a virtual  CPU  for  guest operating systems under the control of the Linux kernel.

intr:这行给出中断的信息,第一个为自系统启动以来,发生的所有中断的次数;然后每个数对应一个特定的中断自系统启动以来所发生的次数,依次对应的是0号中断发生的次数,1号中断发生的次数。。
ctxt:给出了自系统启动以来CPU发生的上下文交换的次数
btime:给出了从系统启动到现在为止的时间,单位为秒
processses:自系统启动以来所创建的认为的数目
procs_running:当前运行队列的任务的数目
procs_blocked:当前被阻塞的任务的数目

处理器使用率:
从/proc/stat中提取4个数据:用户模式(user)、低优先级的用户模式nice、内核模式system以及空闲的处理器时间idle。它们均位于/proc/stat文件第一个行。CPU的利用率使用如下公式来计算:
CPU利用率=100*(user+nice+system)/(user+nice+system+ilde)

/proc/uptime
  1. root@ywx:/proc# cat uptime
  2. 27187.48 16575.31
第一个数值代表系统总的启动时间,第二个则表示系统空闲的时间,都是用秒类表示的

/proc/swaps
显示的是交换分区的使用情况
  1. root@ywx:/proc# cat swaps
  2. Filename                Type        Size    Used    Priority
  3. /dev/sda5 partition    1340412    8    -1
  4. root@ywx:/proc#
看下面的英文解释:
/proc/swaps provides a snapshot of every swap file name(我的是/dev/sda2), the type of swap space(类型是:partition), the total size(我的交换分区总大小996020KB), and the amount of space in use (in kilobytes)(使用了37260KB).
The priority column is useful when multiple swap files are in use. The lower the
priority, the more likely the swap file is to be used.
如果有多个交换分区,如果它的优先级(priority)越小,越容易被使用。





阅读(1920) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~