linux mpstat命令使用详解

发布时间:2022-04-22 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了linux mpstat命令使用详解脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

1. mpstat命令

1.1 命令格式

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的使用情况

$ 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 查看软中断统计信息

$ 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次

$ 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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本宝典。

脚本宝典总结

以上是脚本宝典为你收集整理的linux mpstat命令使用详解全部内容,希望文章能够帮你解决linux mpstat命令使用详解所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: