Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the mpstat command in Linux

Shulou Source: shulou.com Published: 2022-06-01 18:30:56 09月21日 Update

Editor to share with you how to use the mpstat command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux common commands mpstat command instructions are mainly used in multi-CPU environments, it displays the status of each available CPU, and this information is stored in the / proc/stat file.

Mpstat displays the status of each available CPU

Add that in a multi-CPUs system, it can view not only the average status information of all CPU, but also the information of a specific CPU.

Syntax mpstat (option) (parameter) option-P: specifies the CPU number. Parameter interval: interval for each report (seconds)

Times: the number of times the report is displayed.

Instance when the mpstat takes no parameters, the output is the average since the system was started.

Mpstat Linux 2.6.9-5.31AXsmp (builder.redflag-linux.com) 12 soft 16 mpstat Linux 09:38:46 AM CPU% user% nice% system% iowait% soft% idle intr/s 09:38:48 AM all 23.28 0.00 1.75 0.50 0.00 0.00 74.47 1018.59 Statistics report for 2 processors generated every 2 seconds:

The following command produces statistics reports for 2 processors every 2 seconds, generating information for a total of three interval, and then gives the average information for the three interval. By default, the output is sorted by CPU number. The first line gives all the active data since the system was booted. Next, each line corresponds to the active state of a processor.

Mpstat-P ALL 2 3 Linux 2.6.18-164.el5 (server.sys.com) 01ax 04 sys 09:34:20 PM CPU% user% nice% iowait% irq% soft% steal% idle intr/s 09:34:22 PM all 0.00 0.00 0.00 100.00 09:34:22 PM 00.00 0.00 0.50 0.00 0.00 0.00 99.50 1001.00 09:34:22 PM 1 0.00 0.00 0.00 100.00 0.00 compare the results of mpstat with and without parameters:

Open a 2G file in the background

Cat 1.img & then run the mpstat command on another terminal

Mpstat Linux 2.6.18-164.el5 (server.sys.com) 01 user 04 mpstat Linux 10:17:31 PM CPU% user% nice% sys% iowait% irq% steal% idle intr/s 10:17:31 PM all 0.07 0.02 0.25 0.21 0.01 0.04 0.00 99.40 1004.57 mpstat Linux 2.6.18-164.el5 (server.sys.com ) 10:17:35 PM CPU% user% nice% sys% iowait% soft% steal% idle intr/s 10:17:35 PM all 0.07 0.02 0.25 0.21 0.01 0.04 0.00 99.39 1004.73 mpstat 3 10 Linux 2.6.18-164.el5 (server.sys.com) 01Compact 10:17:55 PM CPU User nice sys iowait irq soft steal idle intr/s 10:17:58 PM all 13.12 0.00 20.93 0.00 1.83 9.80 0.00 54.32 10:18:01 PM all 10.82 0.00 19.30 0.83 1.83 9.32 0.00 57.90 10:18:04 PM All 10.95 0.00 20.40 0.17 1.99 8.62 0.00 57.88 2384.05 10:18:07 PM all 10.47 0.00 18.11 0.00 1.50 8.47 0.00 61.46 2416.00 10:18:10 PM all 11.81 0.00 22.63 0.00 1.83 11.98 0.00 51.75 2210.60 10:18:13 PM all 6.31 0.00 10.80 0.00 1.00 5.32 0.00 76.58 1795.33 10:18:19 PM all 1.75 0.00 3.16 0.75 0.25 1.25 0.00 92.85 1245.18 10:18:22 PM all 11.94 0.00 19.07 0.00 1.99 8.29 0.00 58.71 2630.46 10:18:25 PM all 11.65 0.00 19.30 0.50 2.00 9.15 0.00 57.40 2673.91 10:18:28 PM all 11.44 0.00 21.06 0.33 1.99 10.61 0.00 54.56 2369.87 Average: all 9.27 0.00 16.18 0.30 1.50 7.64 0.00 65.11 2173.54 the above two tables show that the system should be reflected correctly. You need to use the parameters of the command correctly. Vmstat and iostat also need to pay attention to this issue.

The above is all the contents of the article "how to use mpstat commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Commands parameters information reports systems processors data status articles processing three content files time times statistics statistics output and then not much Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Shulou Information Linux Microsoft