linux mpstat命令使用详解

吾爱主题 阅读:130 2024-04-05 15:04:19 评论:0

1. mpstat命令

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

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 $ 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 查看软中断统计信息

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 $ 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次

?
1 2 3 4 5 6 7 8 $ 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

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

原文链接:https://segmentfault.com/a/1190000018315256

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容