mpstat (RHEL5默认不安装)

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

mpstat [-P {|ALL}] [internal [count]]

参数的含义如下:

-P {|ALL} 表示监控哪个CPU, cpu在[0,cpu个数-1]中取值

internal 相邻的两次采样的间隔时间

count 采样的次数,count只能和delay一起使用

当没有参数时,mpstat则显示系统启动以后所有信息的平均值。有interval时,第一行的信息自系统启动以来的平均信息。

从第二行开始,输出为前一个interval时间段的平均信息。与CPU有关的输出的含义如下:

[oracle@Test ~]$ mpstat -P ALL

Linux 2.6.18-194.el5 (Test.linux.com)   2010年06月22日

09时18分18秒  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s

09时18分18秒  all    0.06    0.00    0.43    0.78    0.00    0.00    0.00   98.71   1069.35

09时18分18秒    0    0.05    0.00    0.36    0.17    0.02    0.00    0.00   99.41   1032.01

09时18分18秒    1    0.04    0.00    0.42    0.07    0.00    0.00    0.00   99.47      0.26

09时18分18秒    2    0.11    0.00    0.28    0.08    0.00    0.00    0.00   99.52      0.00

09时18分18秒    3    0.07    0.00    0.48    0.05    0.00    0.00    0.00   99.39      0.01

09时18分18秒    4    0.08    0.00    0.19    5.63    0.00    0.02    0.00   94.08     24.51

09时18分18秒    5    0.05    0.00    0.63    0.11    0.00    0.00    0.00   99.21      0.22

09时18分18秒    6    0.07    0.00    0.45    0.10    0.00    0.01    0.00   99.36     12.33

09时18分18秒    7    0.05    0.00    0.64    0.07    0.00    0.00    0.00   99.24      0.00

参数 解释 从/proc/stat获得数据CPU 处理器ID

user 在internal时间段里,用户的CPU时间(%) ,不包含 nice值为负 进程 (usr/total)*100

nice 在internal时间段里,nice值为负进程的CPU时间(%)   (nice/total)*100

system 在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

CPU总的工作时间=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时间前的值。上表中的所有值可取到两位小数点。

范例1:average mode (粗略信息)当mpstat不带参数时,输出为从系统启动以来的平均值。

[work@builder linux-2.6.14]$ mpstat

Linux 2.6.9-5.31AXsmp (builder.redflag-linux.com) 12/16/2005

09:38:46 AM CPU %user %nice %system %iowait %irq %soft %idle intr/s

09:38:48 AM all 23.28 0.00 1.75     0.50 0.00 0.00 74.47 1018.59

范例2: 每2秒产生了2个处理器的统计数据报告

下面的命令可以每2秒产生了2个处理器的统计数据报告,一共产生三个interval 的信息,然后再给出这三个interval的平均信息。默认时,输出是按照CPU 号排序。第一个行给出了从系统引导以来的所有活跃数据。接下来每行对应一个处理器的活跃状态。

[root@server yum_dir]# mpstat -P ALL 2 3

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

09:34:20 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

09:34:22 PM all    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00   1001.49

09:34:22 PM    0    0.00    0.00    0.50    0.00    0.00    0.00    0.00   99.50   1001.00

09:34:22 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00      0.00

09:34:22 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

09:34:24 PM all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   1005.00

09:34:24 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00   1005.50

09:34:24 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00      0.00

09:34:24 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

09:34:26 PM all    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00   1001.49

09:34:26 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00   1001.00

09:34:26 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00      0.00

Average:     CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

Average:     all    0.00    0.00    0.08    0.00    0.00    0.00    0.00   99.92   1002.66

Average:       0    0.00    0.00    0.17    0.00    0.00    0.00    0.00   99.83   1002.49

Average:       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00 100.00      0.00

范例3:比较带参数和不带参数的mpstat的结果。

在后台开一个2G的文件

# cat 1.img &

然后在另一个终端运行mpstat命令

[root@server ~]# cat 1.img &

[1] 6934

[root@server ~]# mpstat

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

10:17:31 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

10:17:31 PM all    0.07    0.02    0.25    0.21    0.01    0.04    0.00   99.40   1004.57

[root@server ~]# mpstat

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

10:17:35 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

10:17:35 PM all    0.07    0.02    0.25    0.21    0.01    0.04    0.00   99.39   1004.73

[root@server ~]# mpstat

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

10:17:39 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

10:17:39 PM all    0.07    0.02    0.25    0.21    0.01    0.04    0.00   99.38   1004.96

[root@server ~]# mpstat

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

10:17:44 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

10:17:44 PM all    0.07    0.02    0.26    0.21    0.01    0.05    0.00   99.37   1005.20

[root@server ~]# mpstat 3 10

Linux 2.6.18-164.el5 (server.sys.com)    01/04/2010

10:17:55 PM CPU   %user   %nice    %sys %iowait    %irq   %soft %steal   %idle    intr/s

10:17:58 PM all   13.12    0.00   20.93    0.00    1.83    9.80    0.00   54.32   2488.08

10:18:01 PM all   10.82    0.00   19.30    0.83    1.83    9.32    0.00   57.90   2449.83

10:18:04 PM all   10.95    0.00   20.40    0.17    1.99    8.62    0.00   57.88   2384.05

10:18:07 PM all   10.47    0.00   18.11    0.00    1.50    8.47    0.00   61.46   2416.00

10:18:10 PM all   11.81    0.00   22.63    0.00    1.83   11.98    0.00   51.75   2210.60

10:18:13 PM all    6.31    0.00   10.80    0.00    1.00    5.32    0.00   76.58   1795.33

10:18:19 PM all    1.75    0.00    3.16    0.75    0.25    1.25    0.00   92.85   1245.18

10:18:22 PM all   11.94    0.00   19.07    0.00    1.99    8.29    0.00   58.71   2630.46

10:18:25 PM all   11.65    0.00   19.30    0.50    2.00    9.15    0.00   57.40   2673.91

10:18:28 PM all   11.44    0.00   21.06    0.33    1.99   10.61    0.00   54.56   2369.87

Average:     all    9.27    0.00   16.18    0.30    1.50    7.64    0.00   65.11   2173.54

[root@server ~]#

上两表显示出当要正确反映系统的情况,需要正确使用命令的参数。vmstat 和iostat 也需要注意这一问题。

linux实时系统监控工具mpstat的更多相关文章

  1. Linux 系统管理命令 - mpstat - CPU信息统计

    命令详解 重要星级: ★★★★☆ 功能说明: mpstat 是 Multiprocessor Statistics 的缩写,是一种实时系统监控工具.mpstat 命令会输出 CPU 的一些统计信息,这 ...

  2. 管理员必备的Linux系统监控工具

    管理员必备的Linux系统监控工具 #1: top - 进程活动 top提供一个当前运行系统实时动态的视图, 也就是正在运行进程.在默认情况下,显示系统 中CPU使用率最高的任务,并每5秒钟刷新一次. ...

  3. 【转】管理员必备的Linux系统监控工具

    原文连接: 管理员必备的Linux系统监控工具 #1: top - 进程活动 top提供一个当前运行系统实时动态的视图,也就是正在运行进程.在默认情况下,显示系统中CPU使用率最高的任务,并每5秒钟刷 ...

  4. linux系统监控工具

    Linux性能监控工具 top   提供运行系统的动态实时视图.显示系统摘要信息以及任务列表 uptime    显示系统平均负载 ps.pstree    提供当前进程列表 free  显示系统中空 ...

  5. LinuxCPU性能监控工具---mpstat

    mpstat是 Multiprocessor Statistics的缩写,是实时系统监控工具.其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中.在多CPU系统里,其不但能查看所有 ...

  6. linux命令总结mpstat命令

    简介 mpstat是Multiprocessor Statistics的缩写,是实时系统监控工具.其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中.在多CPUs系统里,其不但能查 ...

  7. Linux流量监控工具-iftop教程

    Linux流量监控工具-iftop教程http://automationqa.com/forum.php?mod=viewthread&tid=2854&fromuid=2

  8. Linux 流量监控工具 iftop

    Linux 流量监控工具 iftop Iftop工具主要用来显示本机网络流量情况及各相互通信的流量集合,如单独同哪台机器间的流量大小,非常适合于代理服务器和iptables服务器使用,这样可以方便的查 ...

  9. Linux系统性能监控工具介绍之-tsar

    Linux系统性能监控工具介绍之-tsar Linux系统性能监控工具介绍之-tsar 2017-03-02 20:25 175人阅读 评论(0) 收藏 举报  分类: LINUX调优(9)    目 ...

随机推荐

  1. shell与crontab定时器的结合

    crond服务 以守护进程方式在无需人工干预的情况下来处理一些列的作业指令与服务 查看服务状态 systemctl status cron.service 停止服务 systemctl stop cr ...

  2. HDU 3923 Invoker | 暑训Day1 C题填坑

    暑训第一天,专题为组合数学与概率期望. 最近一个月都没有学习新的知识,上午听聚聚讲课头脑都是一片空白.加上长期没刷题,下午做练习题毫无感觉.到晚上总算理清了蓝书上的一些概念,跟着榜单做题.最后唯独剩下 ...

  3. PAT甲级——A1087 All Roads Lead to Rome【30】

    Indeed there are many different tourist routes from our city to Rome. You are supposed to find your ...

  4. PAT甲级——A1083 List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  5. PAT甲级——【牛客练习A1004】

    题目描述 An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For ex ...

  6. Redis —yum安装全过程

    访问 https://redis.io/download 官网,只看这一张图 一路执行完毕即安装成功,下面是执行过程图 看到显示redis的安装路径 接下来要配置下一些参数设置 https://www ...

  7. SpringMVC学习总结

    SpringMVC部分重点组建介绍 前端处理器(DispatcherServlet):接受请求,响应结果,是SpringMVC的核心 处理映射器(HandlerMapping):根据URL去查找处理器 ...

  8. BeanUtils工具类copyProperties方法缺点及解决

    使用类为spring-beans:4.3.13release包中的 org.springframework.beans.BeanUtils BeanUtils.copyProperties(Objec ...

  9. Elasticsearch & Kibana with Shield

    Elasticsearch & Kibana with Shield   官方网站: https://www.elastic.co/guide/en/kibana/current/produc ...

  10. springboot+atomikos+多数据源管理事务(mysql 8.0)

    jta:Java Transaction API,即是java中对事务处理的api 即 api即是接口的意思 atomikos:Atomikos TransactionsEssentials 是一个为 ...