在 CentOS 上使用 cpustat(通常指 sysstat 包的 mpstat/pidstat,或 perf-tools 里的 cpustat,或 Netflix 的 cpustat)时出现卡顿**,一般不是工具本身的问题,而是系统状态或采集方式导致的。下面按常见原因给你梳理:
如果系统负载很高(load average 很大、CPU 使用率接近 100%),cpustat 自身也跑不快,看起来就像“卡住”。
检查:
top
uptime
vmstat 1
如果 us、sy、wa 都很高,说明系统已经卡了。
例如:
cpustat -i 0.01
或同时监控大量 CPU / 进程,会导致:
✅ 建议:
cpustat 1 5
如果 iowait 高,cpustat 在读取 /proc 或写终端时会被拖慢。
检查:
iostat -x 1
若 %util 接近 100%,就是磁盘瓶颈。
通过 SSH 使用时:
也会表现为“卡顿”。
✅ 建议:
cpustat 1 3 > cpu.log
然后本地看日志。
cpustat -C 1
可能卡的原因:
perf 权限不足perf检查:
perf stat ls
dmesg | grep perf
mpstat -P ALL 1
一般不会卡,除非:
/proc/stat 读取异常cat /proc/interrupts
cat /proc/softirqs
网络、NVMe、网卡多队列可能导致 cpustat 卡。
在 Docker / K8s 中:
cat /sys/fs/cgroup/cpu/cpu.stat
uptime
top
vmstat 1
iostat -x 1
mpstat -P ALL 1
dmesg | tail
top / vmstat 的输出我可以直接帮你定位到具体原因。