cpustat 在 CentOS 上不显示或没有这个命令,通常不是系统问题,而是下面几种常见原因之一。我们按最常见情况逐一说明。
cpustat 不是 CentOS 自带命令cpustatcpustat 不是 coreutils、procps-ng 或 sysstat 自带的工具。
常见误区:
topmpstatsarvmstat✅ 这些是 CentOS 自带的
❌ cpustat 不是
cpustat?sysstat 里 没有 cpustat,但有:
mpstat
sar
iostat
✅ 正确用法示例:
mpstat -P ALL 1
如果你是想看 每个 CPU 使用率,直接用它即可。
这是 Brendan Gregg 的 perf-tools 里的工具:
https://github.com/brendangregg/perf-tools
git clone https://github.com/brendangregg/perf-tools.git
cd perf-tools
./cpustat
⚠️ 前提条件:
perfperf:yum install perf
否则会 没有任何输出或报错。
你可能想用的是:
mpstat
或
top
mpstat 也不显示 CPU 数据yum install -y sysstat
mpstat 1 5
CentOS 7/8 显示更完整。
| 需求 | 推荐命令 |
|---|---|
| 实时 CPU 使用率 | top / htop |
| 每个 CPU 统计 | mpstat -P ALL |
| CPU 历史数据 | sar -u |
| 性能分析 | perf top |
| 扩展工具 | cpustat(perf-tools) |
CentOS 默认没有
cpustat,不显示是正常的。
如果你是想看 CPU 使用率,用mpstat或top即可;
如果你确实需要cpustat,它属于第三方 perf-tools,需要单独安装。
如果你愿意,可以把你 执行的命令 + 报错信息贴出来,我可以精确告诉你原因。