温馨提示×

debian cpustat咋配置

小樊
39
2026-09-10 14:53:22
栏目: 智能运维

在 Debian 里,cpustat 通常不是系统自带的核心工具,常见于两种场景:

  1. sysstat 包里的 mpstat / sar(很多人把“看 CPU 状态的工具”统称为 cpustat)
  2. 性能工具 cpustat(由 Oracle 提供的 Go 编写工具)

下面分别说怎么“配置 / 使用”。


一、如果你说的是 sysstat(最常用)

1. 安装

sudo apt update
sudo apt install sysstat

2. 启用数据收集(重要)

默认 不采集数据,需要改配置:

sudo nano /etc/default/sysstat

改成:

ENABLED="true"

3. 重启服务

sudo systemctl restart sysstat

4. 常用命令

mpstat 1          # 实时 CPU 使用
mpstat -P ALL 1   # 每个核心
sar -u 1 5        # CPU 历史/实时
sar -q            # 负载

数据默认存:

/var/log/sysstat/

二、如果你说的是 Oracle 的 cpustat 工具

1. 安装(需 Go)

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

安装后在:

~/go/bin/cpustat

2. 基本用法

sudo ~/go/bin/cpustat 1

示例输出:

cpu  user  sys  idle  intr
 0    5%   2%   93%   1234

3. 常见参数

cpustat 1 10        # 每秒一次,共 10 次
cpustat -C 0,1      # 只看 CPU0/1
cpustat -x          # 扩展信息

三、如果你只是想“配置 CPU 监控”

可以告诉我你是想:

  • 实时看 CPU?
  • 长期记录(画图)?
  • 容器 / 服务器?
  • 用 Prometheus + node_exporter?

我可以直接给你一套配置方案。

0