在 CentOS 上执行 cpustat 没有输出,通常有以下几种常见原因。你可以逐条排查:
cpustat 不是系统自带命令cpustat 不是 CentOS 默认安装的工具,而是来自 sysstat 之外的额外工具(通常是 cpustat by sysstat 作者,或 EPEL 中的工具)。
先确认命令是否存在:
which cpustat
安装方式(常见):
# EPEL
yum install -y epel-release
yum install -y cpustat
某些 cpustat 实现 必须带参数,否则直接退出且无输出。
例如:
cpustat 1 5
表示:每 1 秒采样一次,共 5 次。
如果直接运行:
cpustat
可能:
部分 cpustat 需要读取 /proc 或 perf 相关接口:
sudo cpustat 1 3
如果是普通用户且无权限,可能静默失败。
mpstat很多人把 mpstat 和 cpustat 混淆。
CentOS 自带的是:
mpstat 1 5
来自 sysstat:
yum install -y sysstat
nohup / ssh 时输出未刷新可尝试:
cpustat 1 3 | cat
which cpustat
rpm -q cpustat
sudo cpustat 1 3
如果你能贴出:
cat /etc/redhat-release)cpustat 来源(which / rpm -q)我可以更精确地告诉你原因。