在 Debian 系统上,cpustat 通常不是系统默认安装的工具。它一般来自 perf-tools 或 sysstat 包中的不同实现(常见的是 cpustat by Brendan Gregg 的 perf-tools,或者 Ubuntu/Debian 仓库里的 cpustat 包)。下面我分情况说明如何在 Debian 上使用 cpustat。
cpustat?实际上 sysstat 包里没有叫 cpustat 的命令,相关的是:
mpstatsar如果你只是想看 CPU 利用率,可用:
sudo apt install sysstat
mpstat 1
这是最常见的 cpustat,基于 perf。
sudo apt update
sudo apt install linux-tools-common linux-tools-generic perf
git clone https://github.com/brendangregg/perf-tools.git
cd perf-tools
sudo ./cpustat 1
含义:每 1 秒采样一次 CPU 使用详情。
示例输出字段:
us 用户态sy 内核态ni niceid 空闲wa IO 等待hi 硬中断si 软中断某些 Debian 衍生版提供独立 cpustat 包:
sudo apt install cpustat
运行:
sudo cpustat 1
功能类似,用于周期性显示 CPU 统计。
sudo apt install linux-tools-$(uname -r)
cpustat 通常需要 root:
sudo cpustat 1
sudo cpustat -C 0 1
如果你只是排查性能:
top
htop
mpstat 1
sar -u 1
如果你能告诉我:
cat /etc/os-release)我可以给你更精确的命令示例。