vmstat
进程与系统
用法
vmstat <interval> [count]按固定间隔不断打印内存、交换、磁盘和 CPU 的计数;第一行要丢掉,它是开机以来的平均值而不是此刻,然后先看 si/so 和 wa 两列。
常用选项
| 选项 | 含义 |
|---|---|
| vmstat 1 5 | Five samples, one second apart. |
| -s | A one-off table of memory counters since boot. |
| -w | Wide columns, so the numbers stop colliding. |
| -d | Per-disk statistics instead of the summary. |
| si / so | Swap in and out. Anything sustained here means real memory pressure. |
| wa | Percentage of time the CPU sat waiting for disk. |
示例
vmstat 1 5Five one-second samples; ignore the first line.
vmstat -w 2Keep 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