在 Debian 里,cpustat 通常是指 sysstat 工具包中的 mpstat,或者是 cpustat(来自 cpustat 这个单独工具)。下面分别说明。
mpstat(最常见)sudo apt update
sudo apt install sysstat
sudo systemctl enable sysstat
sudo systemctl start sysstat
mpstat
查看所有 CPU 的平均使用率。
mpstat 1
每 1 秒刷新一次。
mpstat -P ALL 1
查看每一个 CPU 核心的使用情况。
示例输出说明:
%usr:用户态%sys:内核态%iowait:IO 等待%idle:空闲cpustat 工具(更偏向实时监控)sudo apt install cpustat
sudo cpustat
默认每 1 秒刷新一次。
sudo cpustat 2
每 2 秒刷新一次。
特点:
也可以用:
top
htop
(htop 需要 sudo apt install htop)
mpstat -P ALL 1cpustathtop如果你是想监控某个进程、写脚本采集 CPU 数据,或服务器性能排查,可以告诉我,我给你更具体的命令。