温馨提示×

centos cpustat怎么查

小樊
43
2026-10-17 20:35:40
栏目: 智能运维

在 CentOS 上查看 CPU 使用情况,cpustat 通常不是系统默认自带的命令,它一般来自 sysstat 工具包或 pcp(Performance Co-Pilot)。下面分几种常见情况说明:


一、如果你说的是 mpstat / sar(sysstat 包)

CentOS 常用的 CPU 统计工具是 sysstat:

1. 安装 sysstat

yum install -y sysstat

2. 查看 CPU 使用率(类似 cpustat)

mpstat 1

每秒刷新一次 CPU 使用率

mpstat -P ALL 1

查看每个 CPU 核心


二、如果你确实想用 cpustat 命令

cpustat 通常来自 pcp 或某些第三方工具:

1. 安装 pcp(包含 cpustat)

yum install -y pcp

2. 使用 cpustat

cpustat 1

每秒显示一次 CPU 统计


三、最常用、默认的 CPU 查看方式(推荐)

如果不想装额外工具:

1. top

top

按 1 看每个核

2. htop(更友好)

yum install -y epel-release
yum install -y htop
htop

3. 查看 /proc/cpuinfo

lscpu
cat /proc/cpuinfo

四、快速判断你当前有没有 cpustat

which cpustat
  • 有输出 → 已安装
  • 无输出 → 需要安装 pcp 或用 mpstat

如果你能补充:

  • CentOS 版本(6 / 7 / 8 / Stream)
  • 是想看 实时占用 还是 历史统计

我可以给你更精确的命令。

0 踩