mpstat – Report processors related statistics.
What is mpstat?
mpstat is used to monitor cpu utilization on your system. It will be more usefull if your system has multiple processors. The first processors will signed as CPU 0. The second one will be signed CPU 1 and so on. From its manual page, mpstat is described as :
The mpstat command writes to standard output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed. If no activity has been selected, then the default report is the CPU utilization report
For more information about SAR command Click here
mpstat -P ALL 5 1 It shows the various stats for the CPUs in the system. The –P ALL options directs the command to display stats for all the CPUs, not just a specific one. The parameters 5 2 directs the command to run every 5 seconds and for 2 times. The above output shows the metrics for all the CPUs first (aggregated) and for each CPU individually. Finally, the average for all the CPUs has been shown at the end. Let’s see what the column values mean: %user -Indicates the percentage of the processing for that CPU consumes by user processes. User processes are non-kernel processes used for applications such as an Oracle database. In this example output, the user CPU %age is very little. %nice -Indicates the percentage of CPU when a process was downgraded by nice command. The command nice has been described in an earlier installment. It brief, the command nice changes the priority of a process. %system -Indicates the CPU percentage consumed by kernel processes %iowait -Shows the percentage of CPU time consumed by waiting for an I/O to occur %irq -Indicates the %age of CPU used to handle system interrupts %soft -Indicates %age consumed for software interrupts %idle -Shows the idle time of the CPU %intr/s -Shows the total number of interrupts received by the CPU per second it’s possible that a poorly written application not using multi-threaded architecture runs on a multi-processor machine but does not use all the processors. As a result, one CPU overloads while others remain free. You can easily diagnose these sorts of issues via mpstat. [oracle@DEVRAC1 ~]$ mpstat -P ALL 5 1 Linux 2.6.32-431.el6.x86_64 (DEVRAC1) 10/14/2018 _x86_64_ (8 CPU) 11:49:03 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 11:49:08 AM all 12.59 0.03 4.31 1.74 0.00 0.44 0.00 0.00 80.90 11:49:08 AM 0 40.71 0.00 9.81 8.77 0.00 2.09 0.00 0.00 38.62 11:49:08 AM 1 19.35 0.20 5.30 1.63 0.00 0.81 0.00 0.00 72.71 11:49:08 AM 2 9.20 0.00 3.48 1.43 0.00 0.20 0.00 0.00 85.69 11:49:08 AM 3 5.54 0.00 2.67 0.82 0.00 0.21 0.00 0.00 90.76 11:49:08 AM 4 8.20 0.00 5.53 1.02 0.00 0.20 0.00 0.00 85.04 11:49:08 AM 5 8.37 0.00 3.88 0.20 0.00 0.20 0.00 0.00 87.35 11:49:08 AM 6 6.75 0.00 2.45 0.20 0.00 0.00 0.00 0.00 90.59 11:49:08 AM 7 3.27 0.00 1.43 0.00 0.00 0.00 0.00 0.00 95.31 Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle Average: all 12.59 0.03 4.31 1.74 0.00 0.44 0.00 0.00 80.90 Average: 0 40.71 0.00 9.81 8.77 0.00 2.09 0.00 0.00 38.62 Average: 1 19.35 0.20 5.30 1.63 0.00 0.81 0.00 0.00 72.71 Average: 2 9.20 0.00 3.48 1.43 0.00 0.20 0.00 0.00 85.69 Average: 3 5.54 0.00 2.67 0.82 0.00 0.21 0.00 0.00 90.76 Average: 4 8.20 0.00 5.53 1.02 0.00 0.20 0.00 0.00 85.04 Average: 5 8.37 0.00 3.88 0.20 0.00 0.20 0.00 0.00 87.35 Average: 6 6.75 0.00 2.45 0.20 0.00 0.00 0.00 0.00 90.59 Average: 7 3.27 0.00 1.43 0.00 0.00 0.00 0.00 95.31
Report utilization of a single CPU. To do this we use the mpstat command with the -P option followed by the processor number with the first processor being number 0. In the below example we report on CPU utilization statistics for processor number 1 [oracle@DEVRAC1 ~]$ mpstat -P 1 Linux 2.6.32-431.el6.x86_64 (DEVRAC1) 10/14/2018 _x86_64_ (8 CPU) 12:03:23 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 12:03:23 PM 1 1 6.19 0.17 4.13 4.60 0.00 0.47 0.00 0.00 74.44
Print CPU utilization using intervals You may want to see the CPU utilization movement. To do this, you can use intervals. Here's an example. The above command is to show you 4 reports about CPU utilization with 3 seconds intervals [oracle@DEVRAC1 ~]$ mpstat 1 2 Linux 2.6.32-431.el6.x86_64 (DEVRAC1) 10/14/2018 _x86_64_ (8 CPU) 12:05:46 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 12:05:47 PM all 17.18 0.00 3.94 10.56 0.00 0.38 0.00 0.00 67.94 12:05:48 PM all 17.39 0.00 4.99 9.85 0.00 0.64 0.00 0.0 67.14 Average: all 17.28 0.00 4.46 10.20 0.00 0.51 0.00 0.00 67.54
mpstat – Display all information Option -A, displays all the information that can be displayed by the mpstat command as shown below. This is really equalivalent to “mpstat -I ALL -u -P ALL” command. $ mpstat -A
Print all CPU Utilization You can also print every CPU utilization of processors in a single page. Just use -P ALL parameter to do it $ mpstat -P ALL
Catch Me On:- Hariprasath Rajaram Telegram:https://t.me/joinchat/I_f4DhGF_Zifr9YZvvMkRg LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/ Facebook:https://www.facebook.com/HariPrasathdba FB Group:https://www.facebook.com/groups/894402327369506/ FB Page: https://www.facebook.com/dbahariprasath/? Twitter: https://twitter.com/hariprasathdba