vmstat

First row of vmstat shows average measurements since the machine has booted and therefore should be neglected. The vmstat tool cannot be used to show statistics per processor or per core. Use mpstat or ps to show statistics for each processor and core.

The vmstat is a Linux program used to monitor memory on the system. Using the vmstat –help we can see different options for sifting through vmstat output.

// Run 5 times each second
# vmstat 1 5 
  • r: Total number of CPU processes (process queue)
  • b: Blocked processes waiting for disk or network IO
  • swpd: Used virtual memory
  • free: free virtual memory
  • buff: Memory used as buffers (used for storing files within filesystem)
  • cache: Memory used as cache (used for files that have been accessed)
  • si/so: Swapped in and swapped out memory
  • bi/bo: Blocks in and blocks out per second
  • in: Interrupts per second
  • cs: Context switches, how frequently CPU switches between tasks
  • inact: Memory no longer in use
  • active: Memory in use
  • us (user code): Percentage of time spent running non-kernel code
  • sy (system code): Percentage of time spent running kernel code
  • id: Percentage of idle time
  • wa: Percentage of time spent waiting for I/O
  • st (steal time): Percentage of time stolen from virtual machine. In other words, amount of real CPU time the VM has allocated to tasks other than running your virtual machine.
// Write output in megabytes
# vmstat -S M
// Show active/inactive memory
# vmstat -a

Leave a Reply