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