When an enterprise Linux server begins to lag and drop network connections, the first diagnostic step is usually running the top command to check the overall system load. However, standard load averages only provide a generalized summary of the entire machine. If you are running a massive 64-core database server, a single runaway database query might be completely maxing out Core #12, while the other 63 cores sit entirely idle. The generalized system load might look perfectly fine, masking the critical bottleneck. To diagnose multi-core CPU performance with microscopic precision, you must use the mpstat command.
Installing the sysstat Package
Unlike standard diagnostic utilities (like top or free), the mpstat command is not installed on most Linux distributions by default. It is bundled inside a dedicated performance monitoring suite called sysstat.
To install it on Ubuntu or Debian-based systems, run:
sudo apt install sysstat
Once the package finishes installing, the mpstat command becomes immediately available for use.
How to Read Individual CPU Cores
To view a highly detailed, individual breakdown of exactly what every single CPU core on your server is currently doing, you must append the -P ALL flag (Print All).
mpstat -P ALL
The command will output a dense table of data. Look at the column labeled %idle. This metric represents the percentage of time the CPU core spent doing absolutely nothing. If a specific core (e.g., CPU 3) shows a %idle value of 0.00, it means that specific core is completely maxed out and struggling to keep up with the workload.
Running Live Continuous Diagnostics
Running the command once provides a static snapshot of the past millisecond, which is generally useless for diagnosing intermittent lag spikes. To identify a rogue background process, you need to watch the CPU data update live in real-time.
To instruct mpstat to print a brand new report every 2 seconds, continuously, until you force it to stop, simply add the number 2 to the end of the command:
mpstat -P ALL 2
The terminal will instantly begin printing a massive, scrolling table every two seconds, allowing you to easily spot sudden, aggressive spikes in CPU usage across specific hardware cores. When you have finished capturing the diagnostic data, press Ctrl + C to kill the continuous loop and return to your standard bash prompt.