首页·终端命令

vmstat

进程与系统

用法

vmstat <interval> [count]

按固定间隔不断打印内存、交换、磁盘和 CPU 的计数;第一行要丢掉,它是开机以来的平均值而不是此刻,然后先看 si/so 和 wa 两列。

常用选项

选项含义
vmstat 1 5Five samples, one second apart.
-sA one-off table of memory counters since boot.
-wWide columns, so the numbers stop colliding.
-dPer-disk statistics instead of the summary.
si / soSwap in and out. Anything sustained here means real memory pressure.
waPercentage of time the CPU sat waiting for disk.

示例

vmstat 1 5

Five one-second samples; ignore the first line.

vmstat -w 2

Keep sampling every two seconds with readable columns.

看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. vmstat 是做什么的?

按固定间隔不断打印内存、交换、磁盘和 CPU 的计数;第一行要丢掉,它是开机以来的平均值而不是此刻,然后先看 si/so 和 wa 两列。

Q. 怎么写?

vmstat <interval> [count] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 6 个,完整列表在 man vmstat。这条命令属于进程与系统。

相关命令

man 手册: man vmstat