Tuesday, 3 July 2012

The Linux vmstat command

The vmstat command is often overlooked or forgotten by administrators of Linux machines while it contains some nuggets of information otherwise hard to obtain... The vmstat command can provide you with IO blocks sent/received, context switches per second (not to long ago we had a server doing 10000+ context switches due to a software bug, by using vmstat we were able to determine we weren't going insane...), interrupts per second etc

Example output:

root@onms.net:~# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 157312   7832 1034456    0    0   420   358  650  347  7  4 83  7

From the vmstat man page, for translating the fields returned above to geek:

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

       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)

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

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

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

       These are percentages of total 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, included in idle.
       st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

No comments:

Post a Comment