cpustat 在 Debian 上报错,通常不是 Debian 本身的问题,而是命令不存在、包没装、或是用法不对。下面按常见原因给你排查。
cpustat 是什么?cpustat 并不是 Debian 自带的常用命令,它通常来自 sysstat 包,但注意:
sysstat 包里 没有 叫 cpustat 的命令mpstatsariostatpidstat所以如果你直接运行:
cpustat
90% 会报:
command not found
cpustat: command not found原因:系统里根本没有这个命令
✅ 解决方式之一(推荐):
sudo apt update
sudo apt install sysstat
然后用:
mpstat
mpstat -P ALL
mpstat 当成 cpustat 用了很多人误以为 cpustat = mpstat
✅ 正确用法:
mpstat 1
mpstat -P ALL 2
cpustat(非 sysstat)如果你指的是 Go 写的 cpustat 工具(如 github.com/uber-common/cpustat):
报错可能是:
cannot execute binary file
或
no such file or directory
✅ 可能原因:
chmod +x cpustat
./cpustat
某些 CPU 统计需要 root:
sudo mpstat
在 容器 / LXC / 某些 VPS 中:
/proc/stat 被限制可能报错:
Cannot open /proc/stat
✅ 解决:
top
htop
| 你想要的 | 推荐命令 |
|---|---|
| CPU 使用率 | top / htop |
| 每个 CPU 统计 | mpstat -P ALL |
| 历史 CPU 数据 | sar |
| 进程级 CPU | pidstat |
你可以直接把 完整报错信息 贴出来,比如:
cpustat: error while loading shared libraries: ...
或者告诉我:
cat /etc/os-release)我可以精准告诉你该用哪个工具、哪条命令 ✅