温馨提示×

centos cpustat为何没反应

小樊
39
2026-09-12 02:57:17
栏目: 智能运维

在 CentOS 上执行 cpustat 没反应,常见原因和排查方法如下:


1. cpustat 根本没安装

cpustat 不是 CentOS 自带命令,通常来自 sysstatpcp / pcp-system-tools

检查是否存在:

which cpustat

如果没有输出,说明没装。

安装方式

  • sysstat 提供的是 mpstat,不是 cpustat
yum install sysstat
mpstat 1
  • 如果是 pcp 的 cpustat
yum install pcp-system-tools

2. 你实际想用的是 mpstat

很多人把 mpstat 记成 cpustat

mpstat 1

如果 mpstat 有输出而 cpustat 没有,那就对了。


3. 命令在等输入 / 需要参数

某些 cpustat 实现必须带参数,否则“看起来没反应”:

cpustat 1 5

(每秒一次,共 5 次)


4. 权限问题

  • 非 root 用户可能看不到完整 CPU 数据
  • 容器 / 虚拟化环境可能限制 /proc

试试:

sudo cpustat 1

5. 输出被缓冲或重定向

如果你在脚本 / 管道里用:

cpustat > file.log

可能要等一段时间才写盘。


6. 系统太“安静”

如果 CPU 几乎无负载,cpustat 输出间隔很长或变化极小,看起来像卡住。


快速替代方案(推荐)

如果你只是想看 CPU 使用率:

top
htop
vmstat 1
mpstat 1

如果你能贴出:

  • CentOS 版本
  • 你执行的完整命令
  • 是否有报错

我可以更准确判断是哪一类问题。

0