温馨提示×

Debian怎么查看cpustat

小樊
36
2026-07-29 13:54:39
栏目: 智能运维

在 Debian 里查看 CPU 使用率/统计信息,常用的是 sysstat 包里的 mpstat / sar,而不是一个叫 cpustat 的命令(除非你装了第三方工具)。下面按常见情况说明:


一、Debian 默认没有 cpustat,推荐用 mpstat

1️⃣ 安装 sysstat

sudo apt update
sudo apt install sysstat

2️⃣ 查看 CPU 使用情况

mpstat

示例输出:

Linux 6.1.0-amd64 (debian)  2026-01-21  _x86_64_

10:00:01 AM  CPU    %usr   %nice    %sys   %iowait  %irq   %soft  %steal  %guest  %gnice   %idle
10:00:01 AM  all    5.12    0.00    1.23    0.45    0.00    0.10    0.00    0.00    0.00   93.10

3️⃣ 实时刷新(类似 top)

mpstat 1

每秒刷新一次。


二、查看历史 CPU 统计(sar)

如果 sysstat 已启用:

sar -u 1 5

含义:

  • 1:间隔 1 秒
  • 5:共 5 次

三、如果你真的想要 cpustat 命令

cpustatGo 编写的工具,Debian 仓库里一般没有,需要手动安装:

方法 1:用 go 安装(推荐)

sudo apt install golang-go
go install github.com/uber-common/cpustat@latest

安装后:

~/go/bin/cpustat

方法 2:直接下载二进制

wget https://github.com/uber-common/cpustat/releases/latest/download/cpustat
chmod +x cpustat
sudo mv cpustat /usr/local/bin/
cpustat

四、Debian 常用 CPU 查看方式对比

工具 说明
top / htop 实时查看 CPU / 进程
mpstat CPU 核心级统计
sar 历史 + 实时
vmstat CPU + 内存 + IO
iostat CPU + 磁盘
cpustat 进程级 CPU 分析(第三方)

五、快速推荐

  • 日常使用htop
  • 服务器/排查mpstat -P ALL 1
  • 进程级 CPU 分析cpustat

如果你是想 看某个进程占用 CPU,或 分析性能瓶颈,可以告诉我具体场景,我可以给你更精准的命令。

0