温馨提示×

Debian cpustat输出啥

小樊
50
2026-08-14 01:33:19
栏目: 智能运维

cpustat 是一个用来统计 CPU 运行状态 的工具,最常用的是 sysstat 包里带的,或者直接指 mpstat 类工具。在 Debian 上常见用法和输出如下。


一、安装

sudo apt update
sudo apt install sysstat

二、基本用法

cpustat

或指定间隔和次数:

cpustat 1 5

表示 每 1 秒采样一次,共 5 次


三、典型输出内容(示例)

CPU  %usr  %nice %sys  %iowait %irq  %soft %steal %guest %gnice  %idle
all  12.3   0.0   4.1    1.2    0.0   0.3    0.0    0.0    0.0   81.1

四、各列含义详解

字段 含义
CPU all = 所有 CPU 平均;0/1/2… = 单个 CPU
%usr 用户态 CPU 使用率
%nice 低优先级(nice)用户进程
%sys 内核态(system)使用率
%iowait CPU 等待 I/O(磁盘等)
%irq 硬中断
%soft 软中断
%steal 虚拟化中被 hypervisor 抢占
%guest 运行虚拟机 CPU
%gnice nice 后的 guest
%idle 空闲 CPU

100% = 满负载


五、常见场景解释

1️⃣ CPU 很忙

%usr + %sys 接近 100%

说明是 计算密集型

2️⃣ 响应慢但 CPU 空闲

%iowait 很高

通常是 磁盘慢 / 数据库 / swap 问题

3️⃣ 虚拟机卡

%steal 高

宿主机资源被抢占。


六、对比其他工具

工具 特点
top 实时进程
htop 更友好
mpstat CPU 统计(和 cpustat 类似)
vmstat CPU + 内存 + IO
iostat 磁盘重点

七、Debian 特定注意

  • Debian 默认 interval 必须给
cpustat 1

否则可能只输出一次。

  • 数据来自 /proc/stat

如果你愿意,可以把你自己的 cpustat 输出贴出来,我可以帮你分析 到底哪里瓶颈

0