개요
When diagnosing degraded system responsiveness or identifying core-level thread bottlenecks, mpstat serves as an essential diagnostic utility in any Linux administrator’s toolkit. This guide walks through configuring the sysstat suite, mastering common runtime flags, and interpreting multi-core performance metrics under active server workloads.
1. sysstat 패키지 설치 및 mpstat 기본 실행
On Ubuntu systems, the mpstat binary is distributed as part of the sysstat performance monitoring toolkit. Install the package using APT:

Verify the installed release and confirm that the utility is ready for use with mpstat -V:

Executing mpstat samples processor activity and surfaces detailed execution statistics across system CPUs. Running the utility without additional parameters reports average utilization metrics accumulated across all processors since the initial system boot.
⚙️ [주요 옵션]
-P ALL : Displays broken-down performance metrics for every individual logical CPU core independently.-P <CPU> : Filters telemetry specifically for the indicated CPU core index (e.g., 0, 1).-u : Default mode; outputs standard processor load distributions (%usr, %sys, %iowait, %idle, etc.).-I <키워드> : Reports detailed interrupt handling metrics per core (such as SUM, CPU, or SCPU).-A : Produces an all-inclusive telemetry report combining CPU state ratios and interrupt handling activities.

2. 주기적 모니터링 및 실시간 CPU 통계 수집
Running mpstat 2 3 instructs the tool to sample processor activity every two seconds across three consecutive polling cycles, followed by an aggregate summary line (Average).
This polling approach allows engineers to track dynamic load spikes in real time and evaluate shifting usage balances across user space (%usr), kernel threads (%sys), and available capacity (%idle).

3. 코어별 상세 사용률 확인 (-P ALL 옵션)
The command mpstat -P ALL 1 2 collects two one-second sampling passes, displaying independent metric rows for system-wide performance (all) alongside every individual core (ranging from 0 to 5).
This per-core granularity makes it straightforward to pinpoint uneven thread allocation, such as when computational overhead is monopolized by a single processor or disk wait times (%iowait) stall specific execution threads.

To isolate a specific hardware thread, mpstat -P 0 1 2 focuses measurements exclusively on core 0, gathering two sequential one-second samples and outputting the average.
This targeted observation helps analyze core-pinned processes, dedicated background routines, or heavy hardware interrupt processing assigned to a single CPU.

4. 부하 상황 시뮬레이션 및 결과 해석
To validate how metric shifts appear during compute contention, install the synthetic benchmark utility stress:

Launching stress --cpu 2 --timeout 10s & starts two worker threads that fully saturate two processor cores in the background for ten seconds.
This controlled workload drives utilization on targeted cores to 100%, creating an ideal baseline to observe diagnostic tool responses under severe computational pressure.

While the load generator runs, execute mpstat -P ALL 2 3 to sample utilization across all individual cores over three two-second intervals.
Inspecting the output confirms that cores 0 and 4 peak at 100% in user space (%usr) with idle capacity (%idle) plunging to 0%, proving that the background stress processes have been assigned to those specific cores while leaving other processors available.

Monitoring multi-core CPU behavior with mpstat provides immediate transparency into core load distribution and system-level bottlenecks. Applying these sampling techniques enables administrators to quickly diagnose unbalanced thread scheduling and optimize hardware resource allocation across production Ubuntu environments.