linux mpstat command in detail

  • 2021-01-06 00:52:12
  • OfStack

1. mpstat command

1.1 Command Format


mpstat [ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] [ -P { cpu [,...] | ON | ALL } ] [ interval [ count ] ]
[

OPTIONS:

-A: Equipped with -u -I ALL -P ALL
-I: You can specify SUM, CPU, SCPU, ALL4. SUM stands for the total number of interrupts per processor, CPU stands for the number of interrupts per second per core, SCPU stands for the number of soft interrupts per core per second.
-P: Statistical CPU number, usually ALL
-u: Output column information
-ES36en: Check the tool version number

]

2. Use

2.1 Output the usage of all cpu every 1s


$ mpstat -P ALL 1
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019 years 02 month 26 day    _x86_64_  (2 CPU)

12 when 42 points 03 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12 when 42 points 04 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 04 seconds   0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 04 seconds   1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12 when 42 points 04 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12 when 42 points 05 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 05 seconds   0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 05 seconds   1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12 when 42 points 05 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12 when 42 points 06 seconds  all  0.00  0.00  0.00  0.50  0.00  0.00  0.00  0.00  0.00  99.50
12 when 42 points 06 seconds   0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 06 seconds   1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12 when 42 points 06 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12 when 42 points 07 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 07 seconds   0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 07 seconds   1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

12 when 42 points 07 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
12 when 42 points 08 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 08 seconds   0  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
12 when 42 points 08 seconds   1  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
[

Field analysis:
CPU: process id for each CPU
%usr: Utilization rate of cpu in user mode
%nice: Usage rate of CPU for users with nice priority
%sys: Shows the percentage of CPU utilization that occurs when kernel kernel mode is executed. This does not include the time spent maintaining hardware and software interrupts.
%iowait: The percentage of time that CPU or CPU was idle when the system had an outstanding request for disk I/O
%irq: Percentage of time spent by the system serving hard interrupts
%soft: The percentage of time spent by the system servicing soft interrupt overhead
%steal: Shows the percentage of time that virtual CPU or CPU is forced to wait while the hypervisor is servicing another virtual processor
%guest: Time spent by CPU to process virtual processes
%idel: % CPU free

]

2.2 View soft interrupt statistics


$ mpstat -I SCPU 1
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019 years 02 month 26 day    _x86_64_  (2 CPU)

15 when 23 points 07 seconds  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 when 23 points 08 seconds   0    0.00    5.00    0.00    0.00    0.00    0.00    0.00    2.00    0.00    4.00
15 when 23 points 08 seconds   1    0.00   28.00    0.00    5.00    0.00    0.00    0.00   24.00    0.00    3.00
15 when 23 points 09 seconds   0    0.00    6.00    0.00    0.00    2.00    0.00    0.00    3.00    0.00    5.00
15 when 23 points 09 seconds   1    0.00   26.00    0.00   70.00    0.00    0.00    0.00   24.00    0.00    2.00
15 when 23 points 10 seconds   0    0.00   16.00    0.00    0.00    0.00    0.00    0.00   12.00    0.00    3.00
15 when 23 points 10 seconds   1    0.00   13.00    0.00    6.00    0.00    0.00    0.00   13.00    0.00    1.00
15 when 23 points 11 seconds   0    0.00   18.00    0.00    0.00    2.00    0.00    0.00   14.00    0.00    3.00
15 when 23 points 11 seconds   1    0.00   12.00    0.00    5.00    0.00    0.00    0.00   10.00    0.00    1.00
15 when 23 points 12 seconds   0    0.00    8.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    3.00
15 when 23 points 12 seconds   1    0.00   30.00    0.00   40.00    0.00    0.00    0.00   19.00    0.00    4.00
15 when 23 points 13 seconds   0    0.00    7.00    0.00    0.00    2.00    0.00    0.00    3.00    0.00    3.00
15 when 23 points 13 seconds   1    0.00   23.00    0.00    7.00    0.00    0.00    0.00   22.00    0.00    1.00
15 when 23 points 14 seconds   0    0.00   11.00    0.00    0.00    0.00    0.00    0.00    7.00    0.00    6.00
15 when 23 points 14 seconds   1    0.00   30.00    0.00   12.00    1.00    0.00    0.00   25.00    0.00    8.00
15 when 23 points 15 seconds   0    0.00    9.00    0.00    0.00    2.00    0.00    0.00    6.00    0.00    6.00
15 when 23 points 15 seconds   1    0.00   31.00    0.00    7.00    0.00    0.00    0.00   24.00    0.00    5.00
15 when 23 points 16 seconds   0    0.00    8.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    6.00
15 when 23 points 16 seconds   1    0.00   25.00    0.00    6.00    0.00    0.00    0.00   22.00    0.00    3.00
15 when 23 points 17 seconds   0    0.00   10.00    0.00    0.00    2.00    0.00    0.00    6.00    0.00    3.00
15 when 23 points 17 seconds   1    0.00   24.00    0.00    7.00    0.00    0.00    0.00   23.00    0.00    1.00

2.3 Output once every 2s, output 3 times


$ mpstat 2 3
Linux 3.10.0-693.el7.x86_64 (zhanghao)   2019 years 02 month 27 day    _x86_64_  (2 CPU)

02 when 13 points 29 seconds  CPU  %usr  %nice  %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
02 when 13 points 31 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
02 when 13 points 33 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
02 when 13 points 35 seconds  all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00
 The average time : all  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 100.00

Related articles: