在 Debian 下,cpustat 不是一个系统自带的核心命令,它通常来自 sysstat 工具包或 cpustat(Go 编写的小工具)。下面分情况说明怎么“查看”。
mpstat / sar(sysstat 包)很多人说的 “cpustat” 其实是指 CPU 使用率统计。
sudo apt update
sudo apt install sysstat
mpstat 1
每秒刷新一次
查看每个 CPU 核心:
mpstat -P ALL 1
sar -u 1 3
每秒一次,共 3 次
cpustat 命令(Go 工具)sudo apt install golang-go
go install github.com/uber-common/cpustat@latest
运行:
~/go/bin/cpustat
常用:
cpustat 1
top
或
sudo apt install htop
htop
cat /proc/stat
top -bn1 | grep '%Cpu'
| 目的 | 命令 |
|---|---|
| CPU 使用率 | mpstat |
| 历史统计 | sar |
| 实时进程级 | top / htop |
| 真·cpustat | cpustat(Go) |
如果你能说一下:
我可以直接给你最合适的一条命令。