vmstat – A Standard Nifty Tool to Report Virtual Memory Statistics

What’s RAM ?

As we already know about RAM because we all are in smartphone world. So, i don’t want to go in depth, even though i will tell you in single line. RAM stands for Random Access Memory is a computer data storage, which stores frequently used program to increase the system performance.

What’s Virtual Memory ?

virtual memory is a memory management method that allows a computer to balance/manage the shortages of physical memory by temporarily transferring recently unused applications data from RAM to hard disk. Read More

What’s vmstat ?

vmstat is a standard nifty tool that report virtual memory statistics of Linux system. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. It helps Linux administrator to identify system bottlenecks while troubleshooting the issues.

Install Sysstat in Linux

There is no separate package for vmstat on Linux. It’s bundled with sysstat package and available in most of the distribution default repository. If it’s not installed, just fire the following command based on your distribution.

SAR Command Usage

[Install vmstat on CentOS/RHEL]
$ sudo yum install sysstat

[Install vmstat on Fedora]
$ sudo dnf install sysstat

[Install vmstat on Debian/Ubuntu]
$ sudo apt-get install sysstat

[Install vmstat on Arch Linux]
$ sudo pacman -S sysstat

[Install vmstat on Mageia]
$ sudo urpmi sysstat

[Install vmstat on openSUSE]
$ sudo zypper install sysstat

Rum vmstat without parameter

Let’s assume, you have successfully installed vmstat then run the vmstat command on terminal without any parameter which will show you a default result of vmstat.

# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  0  79496 1614120 139240 787928   0    0    23    10    0    0 11  1 88  0

When you saw the above output, you might know few things what it is and the purpose. Don’t worry we will explain each and every parameter deeply, so that you can understand the vmstat usage & purpose.

procs : procs own r & b column which reports about process statistics. In the above output there are two processes in the run queue waiting for CPU & zero sleep process. Usually, it should not exceed number of processors (or cores), if you found abnormal on this better to use top command for further troubleshooting.

  • r : The number of processes waiting for run time.
  • b : The number of processes in sleeping stat.

memory : memory own swpd, free, buff & cache column which reports about memory statistics. The same information you can see with help of free -m command. In the above output memory statistics shows in kilobytes which is bit difficult to understand, better to add M parameter to get the statistics with megabytes.

  • 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.
  • active : The amount of active memory.

swap : swap own si & so column which reports about swap memory statistics. The same information you can see with help of free -m command.

  • si : Amount of memory swapped from disk (memory moved from swap to real memory).
  • so : Amount of memory swapped to disk (memory moved from real memory to swap).

I/O : I/O own bi & bo column which reports about disk read & write statistics per second in terms of blocks read and blocks written. If you found huge I/O read & write better to navigate iotop & iostat command.

  • bi : Number of Blocks received from a block device.
  • bo : Number of Blocks sent to a block device.

system : system own in & cs column which reports about system operations per second. If you found huge I/O read & write better to navigate iotop & iostat command.

  • in : The number of system interrupts per second, including the clock.
  • cs : Number of Blocks sent to a block device.

CPU : CPU own cs, us, sy, id & wa column which reports about CPUs resources percentages of total CPU time. If you found abnormal better to navigate top & free command.

  • cs : The number of system interrupts per second, including the clock.
  • us : Number of Blocks sent to a block device.
  • sy : The amount of memory used as cache.
  • id : The amount of inactive memory.
  • wa : The amount of active memory.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Close
Please support the site
By clicking any of these buttons you help our site to get better