Sunday, 17 April 2016

How to measure CPU usage and performance using vmstat ?


vmstat reports information about processes, memory, paging, block IO, traps, and CPU activity.

vmstat [ -n ] [ delay [count] ]
  • -n : causes the header to be displayed only once rather than periodically.
  • delay : delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
  • count : number of updates. If no count is specified and delay is defined, count defaults to infinity.

vmstat [ -V ]
  • -V : results in displaying version information.

Example
vmstat 1 500


Field description for vm mode

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

Memory
  • 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)

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

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

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

CPU
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, shown as zero.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.