在 Ubuntu 上,cpustat 通常不是系统默认自带的命令,而是来自 sysstat 工具集或 cpustat(Go 编写的性能工具)。下面分情况说明怎么“查看 CPU 状态 / 使用 cpustat”。
mpstat / sar(sysstat 中的 CPU 统计)很多时候大家把 mpstat 误称为 cpustat。
sudo apt update
sudo apt install sysstat
mpstat
每 CPU 核心:
mpstat -P ALL
mpstat 1
sar -u 1 3
cpustat 工具(Go 实现)这是由 tools/eBay/cpustat 提供的工具,功能更详细。
sudo apt install golang-go
go install github.com/rfleenor/cpustat@latest
或下载二进制:
sudo cp ~/go/bin/cpustat /usr/local/bin/
sudo cpustat
常见参数:
sudo cpustat -i 1 # 每 1 秒刷新
sudo cpustat -s user # 按用户排序
也可以用这些命令:
top
htop
nload
cat /proc/stat
lscpu
which cpustat
which mpstat
如果你能贴一下报错信息或你想看的具体内容(比如 CPU 使用率、核心负载、进程级 CPU),我可以直接给你最合适的命令。