在 CentOS 中,cpustat 通常不是系统默认自带命令,它一般来自 sysstat 包(更常见的是 mpstat、sar),或者是 pcp / pcp-zeroconf 提供的 cpustat,也可能是你自己安装的第三方工具。下面分情况说明。
which cpustat
或
cpustat
如果提示:
command not found
说明系统没有安装。
CentOS 一般默认有 mpstat:
mpstat
每秒输出一次,共 3 次:
mpstat 1 3
查看每个 CPU:
mpstat -P ALL 1 2
某些 CentOS(尤其是带 PCP)会有:
cpustat
示例输出(每秒一次,共 5 次):
cpustat 1 5
常用参数:
cpustat -u 1 3 # 用户态 CPU
cpustat -s 1 3 # 系统态 CPU
查看帮助:
man cpustat
如果是第三方 cpustat:
yum install epel-release -y
yum install cpustat -y
然后:
cpustat 1 10
cpustat 1 100 > cpu.log
或后台运行:
nohup cpustat 1 3600 > cpu.log &
不用 cpustat 也可以:
top
或
vmstat 1
或
sar -u 1 3
| 工具 | 是否默认 | 说明 |
|---|---|---|
| mpstat | ✅ | sysstat,最常用 |
| sar | ✅ | 历史/实时 CPU |
| cpustat | ❌ | 需安装(PCP/EPEL) |
| top | ✅ | 交互式 |
如果你能贴一下:
cat /etc/centos-releasewhich cpustatrpm -qf $(which cpustat)(如果有)我可以更精确地告诉你该怎么用。