mpstat is a command that is used to report processor related statistics. It accurately displays the statistics of the CPU usage of the system. It displays information about CPU utilization and performance. It initializes the first processor with CPU 0, the second one with CPU 1, and so on.
Installing mpstat command in linux
In Red Hat based Linux
sudo yum install sysstat
In ubuntu based Linux
sudo apt install sysstat
Working with mpstat Command
1. To display processor and CPU statistics.
This will display all the processor and CPU stats.
2. To display processor number of all CPUs.
mpstat -P ALL
This command will display the processor numbers of all the CPUs working.
3. To get all the information which the tool may collect.
This will display each and every detail of CPU usage.
4. To display CPU utilization by a specific processor.
mpstat -P 0
This will display the CPU utilization by the 0th processor.
5. To display CPU usage with a time interval.
mpstat 1 5
This command will print 5 reports with 1 second time interval.
6. To display mpstat version
This will display the version of the mpstat command installed in your system.
7. To display mpstat help
This command will display mpstat help section