Mpstat命令详解

描述:
mpstat是MultiProcessor Statistics的缩写,是实时系统监控工具。其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中。
在多CPUs系统里,其不但能查看所有CPU的平均状况信息,而且能够查看特定CPU的信息。mpstat的语法如下:

语法:
[root@kqzj ~]# mpstat –help
Usage: mpstat [ options… ] [ [ ] ]
Options are:
[ -P { | ALL } ] [ -V ]

[root@kqzj ~]# mpstat
Linux 2.6.18-194.el5 (kqzj) 2011年01月13日
23时47分13秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
23时47分13秒 all 0.19 0.02 0.41 0.20 0.09 53.61 0.00 45.48 714.95

各値详解:
%user 在internal时间段里,用户态的CPU时间(%),不包含 nice值为负 进程 (usr/total)100
%nice 在internal时间段里,nice值为负进程的CPU时间(%) (nice/total)
100
%sys 在internal时间段里,核心时间(%) (system/total)100
%iowait 在internal时间段里,硬盘IO等待时间(%) (iowait/total)
100
%irq 在internal时间段里,硬中断时间(%) (irq/total)100
%soft 在internal时间段里,软中断时间(%) (softirq/total)
100
%idle 在internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间(%)(idle/total)100
%intr/s 在internal时间段里,每秒CPU接收的中断的次数intr/total)
100

计算公式:
total_cur=user+system+nice+idle+iowait+irq+softirq
total_pre=pre_user+ pre_system+ pre_nice+ pre_idle+ pre_iowait+ pre_irq+ pre_softirq
user=user_cur – user_pre
total=total_cur-total_pre

其中_cur 表示当前值,_pre表示interval时间前的值。上表中的所有值可取到两位小数点。

实例: 每2秒产生了2个处理器的统计数据报告
下面的命令可以每2秒产生了2个处理器的统计数据报告,一共产生三个interval 的信息,然后再给出这三个interval的平
均信息。默认时,输出是按照CPU 号排序。第一个行给出了从系统引导以来的所有活跃数据。接下来每行对应一个处理器的
活跃状态。。
[root@kqzj ~]# mpstat -P ALL 2 3
Linux 2.6.18-194.el5 (kqzj) 2011年01月13日

23时50分09秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
23时50分11秒 all 0.00 0.00 0.00 0.00 0.00 6.91 0.00 93.09 1001.06
23时50分11秒 0 0.00 0.00 0.00 0.00 0.00 6.91 0.00 93.09 1001.06

23时50分11秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
23时50分13秒 all 0.00 0.00 0.00 0.00 0.00 12.95 0.00 87.05 931.61
23时50分13秒 0 0.00 0.00 0.00 0.00 0.00 12.95 0.00 87.05 931.61

23时50分13秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
23时50分15秒 all 0.00 0.00 0.53 0.00 0.53 23.94 0.00 75.00 872.34
23时50分15秒 0 0.00 0.00 0.53 0.00 0.53 23.94 0.00 75.00 872.34

Average: CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
Average: all 0.00 0.00 0.18 0.00 0.18 14.59 0.00 85.06 934.97
Average: 0 0.00 0.00 0.18 0.00 0.18 14.59 0.00 85.06 934.97

文章目录
,