cpustat 并不是 Linux 系统默认自带的标准命令,它通常来自 perf-tools 或 util-linux 中的不同工具,也可能指某些第三方工具。下面按常见情况给你说明下载/安装方式:
cpustat(来自 perf-tools)这是 Brendan Gregg 写的一个 CPU 使用统计脚本(基于 perf)。
git clone https://github.com/brendangregg/perf-tools.git
cd perf-tools
使用:
sudo ./cpustat 1
需要内核支持
perf和ftrace
cpustat(Go 语言版,by uber)这是一个用 Go 写的工具: https://github.com/uber-common/cpustat
go install github.com/uber-common/cpustat@latest
或直接下载二进制:
# 示例(x86_64)
wget https://github.com/uber-common/cpustat/releases/latest/download/cpustat-linux-amd64
chmod +x cpustat-linux-amd64
sudo ./cpustat-linux-amd64
系统自带即可:
top
htop
mpstat -P ALL 1 # 需安装 sysstat
vmstat 1
安装 sysstat:
# Ubuntu / Debian
sudo apt install sysstat
# CentOS / RHEL
sudo yum install sysstat
你可以先运行:
which cpustat
man cpustat
如果你能告诉我:
我可以给你最准确的一条命令。