在 CentOS 系统中,cpustat 通常是 sysstat 工具包的一部分,用于查看 CPU 的使用情况。下面介绍几种常见用法和注意事项。
which cpustat
或
cpustat --help
sudo yum install -y sysstat
在 CentOS 7/8 中,
cpustat来自sysstat包。
cpustat
输出示例(不同版本略有差异):
CPU usr sys idle iowait irq softirq steal guest
all 12 5 80 2 0 0 0 0
字段说明:
cpustat 1 5
表示:
cpustat -c
cpustat -u
| 参数 | 说明 |
|---|---|
-c |
显示每个 CPU 核心 |
-u |
显示 CPU 使用详情 |
-p CPU |
指定某个 CPU |
interval |
采样间隔(秒) |
count |
采样次数 |
示例:
cpustat -c 2 3
有些 CentOS 版本默认 没有 cpustat,可以用以下替代命令:
top
按 1 可查看每个 CPU 核心。
mpstat -P ALL 1
vmstat 1
✅ 推荐查看 CPU 使用顺序:
mpstat -P ALL 1topcpustat(如果已安装)如果你愿意,可以告诉我:
我可以帮你给出更精确的排查命令。