温馨提示×

debian cpustat怎么配

小樊
33
2026-10-25 05:11:25
栏目: 智能运维

在 Debian 上 cpustat 通常指的是 sysstat 包里的 mpstat/sar,或者是 pcp(Performance Co-Pilot)里的 cpustat,还有一种是 Go 写的 cpustat(tools/cpustat)。我先按最常见的情况说明,你看看是哪一种。


一、最常见:sysstat(mpstat / sar)

这是 Debian 上最常用、最容易配置的 CPU 统计工具。

1. 安装

sudo apt update
sudo apt install sysstat

2. 启用数据收集(可选)

编辑配置文件:

sudo vim /etc/default/sysstat

改为:

ENABLED="true"

重启服务:

sudo systemctl restart sysstat

3. 常用命令

mpstat 1          # 每秒显示一次 CPU 使用率
mpstat -P ALL 1   # 每个核心
sar -u 1 5        # 采样 5 次

二、pcp 中的 cpustat(Debian 官方包)

如果你说的是 cpustat 命令本身:

sudo apt install pcp

使用:

cpustat 1

查看帮助:

cpustat --help

三、Go 版 cpustat(GitHub tools/cpustat)

如果你指的是这个: https://github.com/uber-archive/cpustat

安装

需要 Go 环境:

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

运行(需 root):

sudo $HOME/go/bin/cpustat

四、如果你只是想“看 CPU 使用率”

也可以直接用:

top
htop
apt install htop

如果你能告诉我:

  • 是 哪个 cpustat(命令报错信息?)
  • 用途(实时监控 / 日志分析 / 容器?)

我可以给你更精确的配置文件示例。

0 踩