在 CentOS 上如果你想实时查看 CPU 使用情况,常用的是 mpstat(来自 sysstat 包)或 top / htop。下面分别说明。
mpstat 实时查看(推荐,类 cpustat)yum install -y sysstat
mpstat 1
只看所有 CPU 汇总:
mpstat -u 1
查看每个 CPU 核心:
mpstat -P ALL 1
示例输出:
Linux 3.10.0-1160.el7.x86_64 01/10/2026
10:00:01 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
10:00:02 AM all 5.00 0.00 2.00 0.50 0.00 0.00 0.00 0.00 0.00 92.50
cpustat 工具CentOS 默认没有 cpustat,它是 Go 写的一个工具:
go install github.com/uber-common/cpustat@latest
运行:
cpustat 1
top
1 显示每个 CPU 核心q 退出yum install -y epel-release
yum install -y htop
htop
| 工具 | 是否实时 | 是否需安装 | 说明 |
|---|---|---|---|
| mpstat | ✅ | ✅ sysstat | 最像 cpustat |
| top | ✅ | ❌ | 系统自带 |
| htop | ✅ | ✅ | 可视化好 |
| cpustat | ✅ | ✅ Go | 第三方 |
如果你是想看某个进程的 CPU 占用,或者只看 %idle / %iowait,可以告诉我,我给你更精确的命令。