温馨提示×

如何查看Debian cpustat

小樊
52
2026-07-15 07:22:25
栏目: 智能运维

在 Debian 系统中,cpustat 通常来自 sysstat 工具包。下面按常见情况说明如何查看和使用它。


一、确认是否已安装 cpustat

先检查是否存在:

which cpustat

如果提示找不到,说明尚未安装。


二、安装 cpustat(Debian / Ubuntu)

sudo apt update
sudo apt install sysstat

安装完成后即可使用 cpustat


三、常用查看方式

1️⃣ 查看 CPU 使用率(实时)

cpustat

默认会显示 每个 CPU 的使用情况,例如:

CPU  %usr  %nice  %sys  %iowait  %irq  %soft  %steal  %guest  %gnice  %idle
 all  12.3   0.0   3.1     0.5    0.0   0.2     0.0     0.0     0.0   83.9

2️⃣ 指定采样间隔和次数

cpustat 1 5

含义:

  • 1 秒 采样一次
  • 共采样 5 次

3️⃣ 查看所有 CPU(汇总 + 每个核心)

cpustat -c

或:

mpstat -P ALL

mpstat 也是 sysstat 里的工具,信息更详细)


4️⃣ 显示更详细的信息

cpustat -e

可显示中断、上下文切换等扩展信息(取决于版本)。


四、如果系统里没有 cpustat

有些 Debian 版本或最小化安装可能不包含 cpustat,可以用以下替代方案:

✅ 使用 mpstat(推荐)

sudo apt install sysstat
mpstat -P ALL 1

✅ 使用 top / htop

top
htop

✅ 查看 /proc 文件

cat /proc/stat

五、总结

需求 命令
安装 cpustat sudo apt install sysstat
实时查看 CPU cpustat
定时采样 cpustat 1 5
查看每个核心 mpstat -P ALL
更易读 htop

如果你是想 排查 CPU 高负载、做性能分析,或服务器监控,可以告诉我具体场景,我可以给你更针对性的用法。

0