温馨提示×

ubuntu cpustat如何查看

小樊
39
2026-09-28 02:01:35
栏目: 智能运维

在 Ubuntu 上,cpustat 通常不是系统默认自带的命令,而是来自 sysstat 工具集或 cpustat(Go 编写的性能工具)。下面分情况说明怎么“查看 CPU 状态 / 使用 cpustat”。


一、如果你说的是 mpstat / sar(sysstat 中的 CPU 统计)

很多时候大家把 mpstat 误称为 cpustat。

1. 安装 sysstat

sudo apt update
sudo apt install sysstat

2. 查看 CPU 使用情况

mpstat

每 CPU 核心:

mpstat -P ALL

3. 每隔 1 秒刷新一次

mpstat 1

4. 查看历史 CPU 数据(sar)

sar -u 1 3

二、如果你指的是真正的 cpustat 工具(Go 实现)

这是由 tools/eBay/cpustat 提供的工具,功能更详细。

1. 安装(需要 Go)

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

或下载二进制:

sudo cp ~/go/bin/cpustat /usr/local/bin/

2. 使用 cpustat

sudo cpustat

常见参数:

sudo cpustat -i 1      # 每 1 秒刷新
sudo cpustat -s user   # 按用户排序

三、如果只是想“看 CPU 状态”

也可以用这些命令:

top
htop
nload
cat /proc/stat
lscpu

四、快速判断你用的是哪个

which cpustat
which mpstat

如果你能贴一下报错信息或你想看的具体内容(比如 CPU 使用率、核心负载、进程级 CPU),我可以直接给你最合适的命令。

0 踩