
vmstat is a tool that reports information about your
system's Processes, Memory, Swap (Paging), and CPU resource utilization in real
time. It can be used to determine the root cause of
performance and issues related to memory use.
Note: You can also run this command from Non-priviledge user.
When you run vmstat command, It gives you following output.
(Following data provides an average view of virtual memory and system usage
since the last reboot.)
[root@wtuto ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 643348 95616 574256 0 0 40 35 540 861 16 3 80 1 0
Often, the following form of the command is
used:
vmstat [interval] [count]
Example:1. To display vmstat every 5 second, Run following command:
(Press Ctrl + C to stop vmstat process)
[root@wtuto ~]# vmstat 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1188756 38364 490536 0 0 187 53 534 838 17 1 79 3 0
0 0 0 1188804 38376 490528 0 0 1 27 1101 773 1 0 98 0 0
0 0 0 1188968 38376 490536 0 0 0 138 1115 770 4 1 95 0 0
0 0 0 1189000 38384 490528 0 0 0 18 1097 748 1 0 99 0 0
0 0 0 1189000 38388 490536 0 0 1 0 1095 748 1 0 98 0 0
0 0 0 1189000 38396 490536 0 0 0 18 1100 755 1 0 98 0 0
0 0 0 1188876 38404 490540 0 0 0 3 1099 756 1 0 99 0 0
0 0 0 1188876 38420 490540 0 0 2 12 1098 753 1 0 98 0 0
^C
2. To display vmstat every 2 second for 10 times, Run following command:
[root@wtuto ~]# vmstat 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1190416 38092 490340 0 0 202 55 534 836 18 1 78 3 0
0 0 0 1190464 38108 490324 0 0 2 154 1042 777 0 0 99 1 0
0 0 0 1190464 38108 490336 0 0 0 146 1076 820 3 1 96 0 0
0 0 0 1190512 38108 490336 0 0 0 0 1002 621 1 0 100 0 0
0 0 0 1190512 38112 490332 0 0 0 2 1003 625 0 0 100 0 0
0 0 0 1190636 38112 490336 0 0 0 0 1002 656 0 0 100 0 0
1 0 0 1190636 38112 490336 0 0 0 0 1003 653 0 0 100 0 0
0 0 0 1190684 38112 490336 0 0 0 0 1002 639 0 0 100 0 0
0 0 0 1190808 38116 490332 0 0 2 0 1005 588 1 0 100 0 0
0 0 0 1190808 38116 490336 0 0 0 0 1002 641 0 0 99 0 0
To display vmstat output size in KB and MB.
Use k or K with -S swtich to display size in KB. (Where k=1000 bytes and K=1024 bytes)Use m or M with -S switch to display size in MB. (Where m=1000 Kilo-bytes and M=1024 Kilo-bytes)
Note: See the difference in output of following examples:
Example:
1. To display vmstat result using k (small k), Run following command:
[root@wtuto ~]# vmstat -S k
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1308995 35934 437194 0 0 603 87 555 742 12 2 77 9 0
2. To display vmstat result using K (Capital K), Run following command:
[root@wtuto ~]# vmstat -S K
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1276160 35320 427416 0 0 485 76 549 773 11 2 80 8 0
3. To display vmstat result using m (small m), Run following command:
[root@wtuto ~]# vmstat -S m
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1303 36 438 0 0 409 66 544 784 10 2 82 6 0
4. To display vmstat result using M (Capital M), Run following command:
[root@wtuto ~]# vmstat -S M
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1245 34 417 0 0 386 64 543 781 10 2 83 6 0
5. To display vmstat result every 3 second for 5 times using M (Capital M), Run following command:
[root@wtuto ~]# vmstat -S M 3 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1153 38 478 0 0 151 49 532 799 15 1 81 2 0
0 0 0 1152 38 478 0 0 0 80 1009 658 1 0 99 0 0
0 0 0 1165 38 478 0 0 0 0 1003 665 2 0 98 0 0
0 0 0 1165 38 478 0 0 0 53 1010 608 0 0 100 0 0
0 0 0 1165 38 478 0 0 1 0 1040 865 0 0 99 0 0
FIELD DESCRIPTION FOR VM MODE
Procs
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).
IO
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, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.





