LinuxCommandLibrary

mpstat

Report processor related statistics

TLDR

Display CPU statistics every 2 seconds

$ mpstat [2]
copy

Display 5 reports, one by one, at 2 second intervals
$ mpstat [2] [5]
copy

Display 5 reports, one by one, from a given processor, at 2 second intervals
$ mpstat -P [0] [2] [5]
copy

SYNOPSIS

mpstat [ -A ] [ -n interval ] [ -N node ] [ -o file ] [ -P { cpu [,...] | ALL } ] [ interval [ count ] ]

PARAMETERS

-A
    Display all statistics. Equivalent to specifying all options.

-n interval
    Set the interval in seconds.
Note: For backwards compatibility, 'interval' can also be specified as the last parameter.

-N node
    Report statistics for the specified NUMA node. Requires a kernel with NUMA support.

-o file
    Save the output to the specified file.

-P { cpu [,...] | ALL }
    Report statistics for the specified CPU(s). Use ALL to report statistics for each CPU individually. Default is to report system-wide CPU stats.

interval
    Sampling interval in seconds.

count
    Number of reports to generate. If omitted, mpstat runs continuously.

DESCRIPTION

The mpstat (MultiProcessor STATistics) command is a powerful system monitoring tool used in Linux to report CPU-related statistics. It provides detailed insights into processor activity, including CPU utilization, interrupt handling, and task switching. mpstat is part of the `sysstat` package and offers valuable information for identifying performance bottlenecks, understanding CPU load, and troubleshooting performance issues. It can display global CPU stats across all CPUs, or individual stats per CPU core. This helps pinpoint if a specific core is overloaded.

The tool reports on metrics like %user (CPU time spent in user-level processes), %system (CPU time spent in kernel-level processes), %idle (CPU time spent idle), %iowait (CPU time spent waiting for I/O operations), and %irq/%softirq (CPU time spent servicing hardware/software interrupts).
mpstat supports various options for controlling the reporting interval, number of reports, and specific CPU cores to monitor.

UNDERSTANDING OUTPUT FIELDS

%user: Percentage of CPU utilization that occurred while executing at the user level (application).
%nice: Percentage of CPU utilization that occurred while executing at the user level with nice priority.
%system: Percentage of CPU utilization that occurred while executing at the system level (kernel).
%iowait: Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%irq: Percentage of time that the CPU or CPUs were servicing hardware interrupts.
%softirq: Percentage of time that the CPU or CPUs were servicing software interrupts.
%steal: Percentage of time spent in involuntary wait by virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
%guest: Percentage of CPU utilization that occurred while running a virtual processor.
%gnice: Percentage of CPU utilization that occurred while running a niced guest.
%idle: Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

SEE ALSO

vmstat(8), iostat(1), sar(1)

Copied to clipboard