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