在 Debian 上,cpustat 通常是指 sysstat 包里的工具,或者是 cpustat(由 cpustat 工具包提供)。不同工具的“筛选”方式不一样,下面分别说明。
mpstat / sar(常被误叫 cpustat)如果你说的是:
apt install sysstat
那么一般用的是 mpstat。
mpstat -P 1 1
-P 1:只看 CPU11:每 1 秒刷新所有 CPU:
mpstat -P ALL 1
mpstat 1 5
每 1 秒一次,共 5 次。
cpustat 工具(Debian 有)安装:
sudo apt install cpustat
sudo cpustat -p nginx
只看 nginx 相关进程。
sudo cpustat -u root
sudo cpustat -t 5
只显示 CPU 使用率 > 5% 的进程。
sudo cpustat 1 10
每 1 秒,共 10 次。
sudo cpustat -p java -t 2 1 5
toptop -p 1234
htophtop
然后按:
F4 过滤进程名F2 设置只显示某些 CPU| 需求 | 命令 |
|---|---|
| 看某个 CPU | mpstat -P 1 |
| 看某进程 | cpustat -p nginx |
| 看某用户 | cpustat -u root |
| 按 CPU 阈值 | cpustat -t 5 |
| 定时采样 | cpustat 1 10 |
如果你能告诉我:
我可以给你更精确的命令。