• Monitoring Disk I/O, CPU Usage, Memory Usage, and Swap with vmstat on Unix

Monitoring Disk I/O, CPU Usage, Memory Usage, and Swap with vmstat on Unix

vmstat is a very useful command found on Linux and other Unix distributions that allows for real-time monitoring of most health vitals. Explained here is how to interpret the output of this command and it’s most basic usage. This article is intended as a reference for interpreting vmstat output, and not as a primer on monitoring server resources, as that is a much more in-depth topic. To run vmstat, type vmstat and the number (in seconds) that you want to grab a snapshot of the system’s disk performance, CPU usage, memory usage and swap space usage. On my system here, I am running vmstat 1:


procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  1    208 394864   3696 2099444    0    0     0     2    0     0  1  0 98  1
 0  1    208 394416   3696 2099704    0    0     0     0 1451   533  0  1 75 25
 0  1    208 393776   3696 2100484    0    0     0     0 1508   474  1  0 75 24
 0  1    208 393328   3696 2101004    0    0     0     0 1506   584  0  0 75 25
 0  1    208 392816   3712 2101248    0    0     0   108 1370   377  0  0 74 25
 0  1    208 392176   3720 2101760    0    0     0    16 1500   589  0  0 75 25
 0  1    208 391728   3720 2102280    0    0     0     0 1373   383  1  0 75 24
 0  1    208 391280   3720 2102800    0    0     0     0 1464   564  0  0 75 25
 0  1    208 390928   3720 2103060    0    0     0     0 1315   317  0  0 75 25

The output is categorized in the following sections:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa

Here is a breakdown of the Procs output of vmstat:

       r: The number of processes waiting for run time.
       b: The number of processes in uninterruptible sleep.

Here is a breakdown of the Memory output of vmstat:

       swpd: the amount of virtual memory used.
       free: the amount of idle memory.
       buff: the amount of memory used as buffers.
       cache: the amount of memory used as cache.
       inact: the amount of inactive memory. (-a option)
       active: the amount of active memory. (-a option

Here is a breakdown of the Swap output of vmstat:

       si: Amount of memory swapped in from disk (/s).
       so: Amount of memory swapped to disk (/s).

Here is a breakdown of the I/O output of vmstat:

       bi: Blocks received from a block device (blocks/s).
       bo: Blocks sent to a block device (blocks/s).

Here is a breakdown of the System output of vmstat:

      in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.

Here is a breakdown of the System output of vmstat:

       All of the following metrics are measured in percentage of CPU time.
       us: Time spent running non-kernel code. (user time, including nice time)
       sy: Time spent running kernel code. (system time)
       id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
       wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • BlogMemes
  • Furl
  • LinkedIn
  • MySpace
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Tumblr
  • TwitThis
  • Fark
  • Yahoo! Buzz

Leave a Reply

You must be logged in to post a comment.