在 Ubuntu 里,cpustat 不是一个默认就装好的命令,它通常来自 sysstat 工具包,或者是 perf-tools / cpustat 这类工具。下面分情况说:
mpstat / sar(sysstat 里的 CPU 统计)这是最常见的“cpustat”类工具。
sudo apt update
sudo apt install sysstat
mpstat
mpstat 1
sar -u 1
mpstat:查看 CPU 使用率sar -u:历史/实时 CPU 统计cpustat(来自 perf-tools)这是 Brendan Gregg 写的工具,用来按进程看 CPU 占用。
sudo apt install cpustat
或手动:
git clone https://github.com/brendangregg/perf-tools
sudo cpustat
sudo cpustat 1
⚠️ 通常需要 root 权限
可以用这些:
htop
top
nmon
安装:
sudo apt install htop nmon
which cpustat
which mpstat
如果你能告诉我:
我可以给你更精确的命令。