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

How to create LVM for XFS file system in Ubuntu

Preface lvm (Logical Volume Manager) logical volu...

Common tags in XHTML

What are XHTML tags? XHTML tag elements are the b...

How to quickly modify the host attribute of a MySQL user

When you log in to MySQL remotely, the account yo...

Pure CSS3 to create page switching effect example code

The one I wrote before is too complicated, let’s ...

Linux command line operation Baidu cloud upload and download files

Table of contents 0. Background 1. Installation 2...

Insufficient memory problem and solution when docker starts elasticsearch

question Insufficient memory when docker installs...

How to allow remote connection in MySql

How to allow remote connection in MySql To achiev...

CSS implements six adaptive two-column layout methods

HTML structure <body> <div class="w...

How to modify the "Browse" button of the html form to upload files

Copy code The code is as follows: <!DOCTYPE HT...

Detailed explanation of MySQL batch SQL insert performance optimization

For some systems with large amounts of data, the ...

What kinds of MYSQL connection queries do you know?

Preface If the query information comes from multi...

Getting Started with Nginx Reverse Proxy

Table of contents Overview The role of reverse pr...

Detailed introduction to CSS priority knowledge

Before talking about CSS priority, we need to und...