前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux mpstat命令使用详解

linux mpstat命令使用详解

作者头像
砸漏
发布2020-10-19 14:45:16
2.2K0
发布2020-10-19 14:45:16
举报
文章被收录于专栏:恩蓝脚本恩蓝脚本

1. mpstat命令

1.1 命令格式

代码语言:javascript
复制
mpstat [ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] [ -P { cpu [,...] | ON | ALL } ] [ interval [ count ] ]

OPTIONS: -A: 等同于-u -I ALL -P ALL -I:可以指定SUM CPU SCPU ALL四个参数,SUM表示每个处理器的中断总数,CPU表示每个核的每秒中断数量, SCPU表示每个核每秒的软中断数量,内核版本在2.6.31之后才支持。 -P: 统计的CPU编号,一般用ALL -u: 输出列的信息 -V: 查看工具版本号

2. 使用

2.1 每隔1s输出所有cpu的使用情况

代码语言:javascript
复制
$ mpstat -P ALL 1
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019年02月26日   _x86_64_  (2 CPU)

12时42分03秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12时42分04秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分04秒  0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分04秒  1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12时42分04秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12时42分05秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分05秒  0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分05秒  1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12时42分05秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12时42分06秒 all  0.00  0.00  0.00  0.50  0.00  0.00  0.00  0.00  0.00  99.50
12时42分06秒  0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分06秒  1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12时42分06秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12时42分07秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分07秒  0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分07秒  1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12时42分07秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12时42分08秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分08秒  0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12时42分08秒  1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

字段分析: CPU: 每个CPU的process id %usr: 用户态下,cpu的利用率 %nice: 具有nice优先级的用户下,CPU的使用率 %sys: 显示在kernel内核态执行时发生的CPU利用率百分比。这不包括维护硬件和软件中断所花费的时间。 %iowait: 显示系统有未完成的磁盘I/O请求时,CPU或CPU处于空闲状态的时间百分比 %irq: 系统服务于硬中断的时间开销的百分比 %soft: 系统服务于软中断开销的时间开销百分比 %steal: 显示虚拟CPU或CPU在虚拟机监控程序为另一个虚拟处理器提供服务时被迫等待所花费的时间百分比 %guest: CPU处理虚拟进程的花费的时间开销 %idel: CPU空闲百分比

2.2 查看软中断统计信息

代码语言:javascript
复制
$ mpstat -I SCPU 1
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019年02月26日   _x86_64_  (2 CPU)

15时23分07秒 CPU    HI/s  TIMER/s  NET_TX/s  NET_RX/s  BLOCK/s BLOCK_IOPOLL/s TASKLET/s  SCHED/s HRTIMER/s   RCU/s
15时23分08秒  0    0.00    5.00    0.00    0.00    0.00    0.00    0.00    2.00    0.00    4.00
15时23分08秒  1    0.00   28.00    0.00    5.00    0.00    0.00    0.00   24.00    0.00    3.00
15时23分09秒  0    0.00    6.00    0.00    0.00    2.00    0.00    0.00    3.00    0.00    5.00
15时23分09秒  1    0.00   26.00    0.00   70.00    0.00    0.00    0.00   24.00    0.00    2.00
15时23分10秒  0    0.00   16.00    0.00    0.00    0.00    0.00    0.00   12.00    0.00    3.00
15时23分10秒  1    0.00   13.00    0.00    6.00    0.00    0.00    0.00   13.00    0.00    1.00
15时23分11秒  0    0.00   18.00    0.00    0.00    2.00    0.00    0.00   14.00    0.00    3.00
15时23分11秒  1    0.00   12.00    0.00    5.00    0.00    0.00    0.00   10.00    0.00    1.00
15时23分12秒  0    0.00    8.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    3.00
15时23分12秒  1    0.00   30.00    0.00   40.00    0.00    0.00    0.00   19.00    0.00    4.00
15时23分13秒  0    0.00    7.00    0.00    0.00    2.00    0.00    0.00    3.00    0.00    3.00
15时23分13秒  1    0.00   23.00    0.00    7.00    0.00    0.00    0.00   22.00    0.00    1.00
15时23分14秒  0    0.00   11.00    0.00    0.00    0.00    0.00    0.00    7.00    0.00    6.00
15时23分14秒  1    0.00   30.00    0.00   12.00    1.00    0.00    0.00   25.00    0.00    8.00
15时23分15秒  0    0.00    9.00    0.00    0.00    2.00    0.00    0.00    6.00    0.00    6.00
15时23分15秒  1    0.00   31.00    0.00    7.00    0.00    0.00    0.00   24.00    0.00    5.00
15时23分16秒  0    0.00    8.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    6.00
15时23分16秒  1    0.00   25.00    0.00    6.00    0.00    0.00    0.00   22.00    0.00    3.00
15时23分17秒  0    0.00   10.00    0.00    0.00    2.00    0.00    0.00    6.00    0.00    3.00
15时23分17秒  1    0.00   24.00    0.00    7.00    0.00    0.00    0.00   23.00    0.00    1.00

2.3 每隔2s输出一次,输出3次

代码语言:javascript
复制
$ mpstat 2 3
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019年02月27日   _x86_64_  (2 CPU)

02时13分29秒 CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
02时13分31秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
02时13分33秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
02时13分35秒 all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
平均时间: all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

以上就是本文的全部内容,希望对大家的学习有所帮助。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-09-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档