在 Ubuntu 中,cpustat 通常是指 sysstat 工具包里的 mpstat / sar 相关工具,或者是指 cpustat(由 Colin Ian King 开发的工具,包名通常也叫 cpustat)。下面分别说明它们能“测什么”。
cpustat(推荐说明)包名:cpustat
安装:
sudo apt install cpustat
cpustat 主要用于按进程/线程统计 CPU 使用情况,比 top 更底层、更精确。
主要功能包括:
sudo cpustat 1 5
每 1 秒采样一次,共 5 次。
输出示例信息:
如果你指的是 mpstat 或 sar:
mpstat -P ALL 1
测:
sar -u 1 3
测:
✅ 适合:
❌ 不适合:
free / vmstat)iostat)iftop / sar -n)Ubuntu 的 cpustat 可以精确测量“谁、在哪个 CPU、用了多少 CPU 时间”,是分析 CPU 性能瓶颈的利器。
如果你愿意,我可以给你一个实战排查 CPU 100% 的例子。