温馨提示×

debian怎么用cpustat查看cpu

小樊
41
2026-09-07 16:39:19
栏目: 智能运维

在 Debian 里,cpustat 通常是指 sysstat 工具包中的 mpstat,或者是 cpustat(来自 cpustat 这个单独工具)。下面分别说明。


一、使用 sysstat 中的 mpstat(最常见)

1. 安装

sudo apt update
sudo apt install sysstat

2. 启用统计(可选)

sudo systemctl enable sysstat
sudo systemctl start sysstat

3. 基本用法

mpstat

查看所有 CPU 的平均使用率。

mpstat 1

每 1 秒刷新一次。

mpstat -P ALL 1

查看每一个 CPU 核心的使用情况。

示例输出说明:

  • %usr:用户态
  • %sys:内核态
  • %iowait:IO 等待
  • %idle:空闲

二、使用独立的 cpustat 工具(更偏向实时监控)

1. 安装

sudo apt install cpustat

2. 使用

sudo cpustat

默认每 1 秒刷新一次。

sudo cpustat 2

每 2 秒刷新一次。

特点:

  • 显示每个进程的 CPU 占用
  • 适合排查“哪个进程吃 CPU”

三、如果你只是想快速看 CPU 使用率

也可以用:

top
htop

(htop 需要 sudo apt install htop


总结

  • 看整体/每核 CPU 使用率mpstat -P ALL 1
  • 看进程级 CPU 占用cpustat
  • 交互式查看htop

如果你是想监控某个进程写脚本采集 CPU 数据,或服务器性能排查,可以告诉我,我给你更具体的命令。

0