在 CentOS 上执行 cpustat 没反应,常见原因和排查方法如下:
cpustat 根本没安装cpustat 不是 CentOS 自带命令,通常来自 sysstat 或 pcp / pcp-system-tools。
检查是否存在:
which cpustat
如果没有输出,说明没装。
mpstat,不是 cpustatyum install sysstat
mpstat 1
yum install pcp-system-tools
mpstat很多人把 mpstat 记成 cpustat。
mpstat 1
如果 mpstat 有输出而 cpustat 没有,那就对了。
某些 cpustat 实现必须带参数,否则“看起来没反应”:
cpustat 1 5
(每秒一次,共 5 次)
/proc试试:
sudo cpustat 1
如果你在脚本 / 管道里用:
cpustat > file.log
可能要等一段时间才写盘。
如果 CPU 几乎无负载,cpustat 输出间隔很长或变化极小,看起来像卡住。
如果你只是想看 CPU 使用率:
top
htop
vmstat 1
mpstat 1
如果你能贴出:
我可以更准确判断是哪一类问题。