cpustat 本身不是用来查看内存的,它主要用于统计 CPU 使用情况。
如果你在 CentOS 上想看 内存,一般不用 cpustat,而是用下面这些工具。
cpustat 来自 sysstat 包,主要输出:
不包含内存信息。
free(最常用)free -h
示例输出:
total used free shared buff/cache available
Mem: 7.8G 2.1G 1.2G 120M 4.5G 5.2G
Swap: 2.0G 0B 2.0G
含义:
✅ 推荐看 available
top(实时查看)top
在顶部可以看到:
MiB Mem : 8000.0 total, 1200.0 free, 2100.0 used, 4700.0 buff/cache
按:
M:按内存排序q:退出htop(更直观,需安装)yum install -y htop
htop
vmstat(内存 + CPU 一起看)vmstat 1
内存相关字段:
swpd:交换分区使用free:空闲内存buff / cache:缓存/proc/meminfo(最底层)cat /proc/meminfo
常用字段:
MemTotal
MemFree
MemAvailable
Buffers
Cached
SwapTotal
SwapFree
cpustat
❌ 不能看内存
✅ 只能看 CPU 使用率,例如:
CPU user nice system idle iowait
all 10.2 0.0 5.1 82.3 2.4
| 目的 | 命令 |
|---|---|
| 快速看内存 | free -h ✅ |
| 实时查看 | top / htop ✅ |
| 内存 + CPU | vmstat 1 |
| 内存详情 | /proc/meminfo |
如果你愿意,我也可以帮你:
free -h 的输出是否异常