温馨提示×

debian下cpustat怎查看

小樊
42
2026-09-19 23:00:55
栏目: 智能运维

在 Debian 下,cpustat 不是一个系统自带的核心命令,它通常来自 sysstat 工具包或 cpustat(Go 编写的小工具)。下面分情况说明怎么“查看”。


一、先确认你是不是指 mpstat / sar(sysstat 包)

很多人说的 “cpustat” 其实是指 CPU 使用率统计

1. 安装 sysstat

sudo apt update
sudo apt install sysstat

2. 查看 CPU 实时状态(类似 cpustat)

mpstat 1

每秒刷新一次

查看每个 CPU 核心:

mpstat -P ALL 1

3. 查看历史 CPU 统计(sar)

sar -u 1 3

每秒一次,共 3 次


二、如果你确实想用 cpustat 命令(Go 工具)

1. 安装 cpustat(需 Go)

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

运行:

~/go/bin/cpustat

常用:

cpustat 1

三、不想装软件?用自带命令也行

1. top / htop

top

sudo apt install htop
htop

2. /proc/stat 原始查看

cat /proc/stat

3. 快速看 CPU 占用

top -bn1 | grep '%Cpu'

四、总结对照表

目的 命令
CPU 使用率 mpstat
历史统计 sar
实时进程级 top / htop
真·cpustat cpustat(Go)

如果你能说一下:

  • 是想看 整体 CPU 占用 还是 某进程 CPU
  • 还是 每个核

我可以直接给你最合适的一条命令。

0