Detailed explanation of Linux mpstat command usage

Detailed explanation of Linux mpstat command usage

1. mpstat command

1.1 Command Format

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

OPTIONS:

-A: equivalent to -u -I ALL -P ALL
-I: You can specify four parameters: SUM CPU SCPU ALL. SUM indicates the total number of interrupts for each processor, CPU indicates the number of interrupts per second for each core, and SCPU indicates the number of soft interrupts per second for each core. This is supported only after kernel versions 2.6.31.
-P: The CPU number to be counted, usually ALL
-u: Output column information
-V: View tool version number

2. Use

2.1 Output all CPU usage every 1s

$ mpstat -P ALL 1
Linux 3.10.0-693.el7.x86_64 (zhanghao) February 26, 2019_x86_64_ (2 CPUs)

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:041 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:05all 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:051 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:06all 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:061 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:071 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:081 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 of each CPU
%usr: CPU utilization in user mode
%nice: CPU usage for users with nice priority
%sys: Displays the percentage of CPU utilization that occurred while executing in kernel mode. This does not include the time spent maintaining hardware and software outages.
%iowait: Displays the percentage of time the CPU or CPU is idle when the system has outstanding disk I/O requests
%irq: The percentage of time the system spends servicing hard interrupts
%soft: The percentage of time the system spends servicing soft interrupt overhead
%steal: Displays the percentage of time a virtual CPU or CPUs spent waiting while the hypervisor was servicing another virtual processor.
%guest: CPU time spent processing virtual processes
%idel: CPU idle percentage

2.2 Viewing soft interrupt statistics

$ mpstat -I SCPU 1
Linux 3.10.0-693.el7.x86_64 (zhanghao) February 26, 2019_x86_64_ (2 CPUs)

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:081 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:091 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 hours 23 minutes 15 seconds 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:161 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 Output once every 2 seconds, output 3 times

$ mpstat 2 3
Linux 3.10.0-693.el7.x86_64 (zhanghao) February 27, 2019_x86_64_ (2 CPUs)

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:35all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average time: all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the use of stat function and stat command in Linux
  • How to use ss command instead of netstat in Linux operation and maintenance
  • Tutorial on using iostat command in Linux
  • Detailed explanation of Linux command iostat
  • Detailed discussion of Linux netstat command (essential for senior interviews)
  • Some common uses of the netstat command in Linux
  • Detailed explanation of Linux netstat command
  • How to view the number of concurrent connections using the Linux netstat command
  • Use mysqladmin extended-status with Linux commands to view MySQL running status in Linux
  • Use of Linux stat command

<<:  Organize the common knowledge points of CocosCreator

>>:  How to uninstall MySQL 5.7.19 under Linux

Recommend

N ways to achieve two-column layout with CSS

1. What is a two-column layout? There are two typ...

Briefly talk about mysql left join inner join

Preface I have been busy developing a cold chain ...

Sample code for converting video using ffmpeg command line

Before starting the main text of this article, yo...

How to enable TLS and CA authentication in Docker

Table of contents 1. Generate a certificate 2. En...

A brief discussion on the types of node.js middleware

Table of contents Overview 1. Application-level m...

CentOS 8.0.1905 installs ZABBIX 4.4 version (verified)

Zabbix Server Environment Platform Version: ZABBI...

When backing up files in Centos7, add the backup date to the backup file

Linux uses files as the basis to manage the devic...

How to clean up Alibaba Cloud MySQL space

Today I received a disk warning notification from...

MySQL data operation-use of DML statements

illustrate DML (Data Manipulation Language) refer...

How to implement horizontal bar chart with percentage in echarts

Table of contents Example Code Rendering Code Ana...

JS achieves five-star praise case

This article shares the specific code of JS to ac...

The w3c organization gives style recommendations for html4

This is the style recommendation given by the W3C ...

Intellij IDEA quick implementation of Docker image deployment method steps

Table of contents 1. Docker enables remote access...

How to set default value for datetime type in MySQL

I encountered a problem when modifying the defaul...