Hack 97. vmstat Command Examples

by Ramesh

For a typical performance monitoring all you need is only vmstat command. This display memory, swap, IO, system and cpu performance information.The following command executes vmstat every 1 second for 100 times.

  1. # vmstat 1 100
  2. procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
  3. r b swpd free buff cache si so bi bo in cs us sy id wa
  4. 0 0 0 282120 134108 5797012 0 0 0 2 0 0 0 0 100 0
  5. 0 0 0 282120 134108 5797012 0 0 0 0 1007 359 0 0 100 0
  6. 0 0 0 282120 134108 5797012 0 0 0 0 1117 577 0 0 100 0
  7. 0 0 0 282120 134108 5797012 0 0 0 0 1007 366 0 0 100 0

Vmstat procs Section

  • r field: Total number of runnable process
  • b field: Total number of blocked process

Memory section

  • Swpd field: Used swap space
  • Free field: Available free RAM
  • Buff field: RAM used for buffers
  • Cache field: RAM used for filesystem cache

Swap Section

  • Si field: Amount of memory swapped from disk per second
  • So field: Amount of memory swapped to disk per second

IO Section

  • Bi field: Blocks received from disk
  • Bo field: Blocks sent to disk.

System Section

  • In field: Number of interrupts per second.
  • Cs field: Number of context switches per second.

CPU Section

  • Us field: Time spend running user code. (non-kernel code)
  • Sy field: Time spent running kernel code.
  • Id field: Idle time.
  • Wa field: Time spent waiting for the IO