Monitoring the memory usage of system by using vmstat
Monitoring the memory usage of system by using vmstat
vmstat &ndash virtual memory statistics is a system monitoring tool which collects and displays summary information about OS memory, processes and block I/O. This guide illustrates steps to monitor Linux memories by using vmstat.
Using vmstat without any option
The free and swap are the important fields. The free shows the amount of free and idle memory space. In swap, si stands for swaped in every seconds from the disk in KB’ s and so stands for swaped out every seconds from the disk in KB’ s.
[root@linuxhelp Desktop]# 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 113840 175352 15384 167248 2 7 169 33 103 191 3 1 95 1 0
To check the version of the vmstat
Use the option &ndash V with vmstat to check the version of the vmstat.
[root@linuxhelp Desktop]# vmstat -V
procps version 3.2.8
To display the statistic result with some time interval and also some line count
[root@linuxhelp Desktop]#vmstat 2 6
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 114040 63604 9372 212452 2 7 173 33 104 193 3 1 95 1 0
0 0 114040 63464 9380 212440 0 0 0 54 141 270 6 1 93 0 0
0 0 114040 63340 9380 212440 0 0 0 0 131 246 6 0 94 0 0
0 0 114040 63340 9380 212440 0 0 0 0 134 265 6 1 93 0 0
0 0 114040 63216 9384 212440 0 0 0 2 145 322 6 1 92 1 0
0 0 114040 63216 9384 212440 0 0 0 0 103 167 4 0 96 0 0
To display the summary of various event counters
Now using option &ndash s display the summary of various event counters and memory statistic.
[root@linuxhelp Desktop]# vmstat -s
1012448 total memory
922588 used memory
351332 active memory
465908 inactive memory
89860 free memory
9792 buffer memory
219536 swap cache
2047996 total swap
114036 used swap
1933960 free swap
57153 non-nice user cpu ticks
38 nice user cpu ticks
10900 system cpu ticks
1573431 idle cpu ticks
18472 IO-wait cpu ticks
372 IRQ cpu ticks
995 softirq cpu ticks
0 stolen cpu ticks
2845533 pages paged in
546273 pages paged out
7503 pages swapped in
29841 pages swapped out
1729962 interrupts
To check the disk statistics of your system
To check the disk statistics of your system with help of option &ndash d.
[root@linuxhelp Desktop]# vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
ram0 0 0 0 0 0 0 0 0 0 0
ram1 0 0 0 0 0 0 0 0 0 0
ram2 0 0 0 0 0 0 0 0 0 0
ram3 0 0 0 0 0 0 0 0 0 0
ram4 0 0 0 0 0 0 0 0 0 0
ram5 0 0 0 0 0 0 0 0 0 0
ram6 0 0 0 0 0 0 0 0 0 0
ram7 0 0 0 0 0 0 0 0 0 0
ram8 0 0 0 0 0 0 0 0 0 0
ram9 0 0 0 0 0 0 0 0 0 0
.
.
.
.
loop5 0 0 0 0 0 0 0 0 0 0
loop6 0 0 0 0 0 0 0 0 0 0
disk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
loop7 0 0 0 0 0 0 0 0 0 0
sr0 0 0 0 0 0 0 0 0 0 0
sda 51651 30205 5687491 499863 14650 122154 1094554 691071 0 263
To display in MB
The memory statistic will be displayed in MB(megabyte) format at vmstat terminal.
[root@linuxhelp Desktop]# 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
1 0 118 70 10 208 0 0 168 32 105 198 3 1 95 1 0
To display the slap info results
By using &ndash m option with vmstat it will display the slap info results.
[root@linuxhelp Desktop]# vmstat -m
Cache Num Total Size Pages
rpc_buffers 8 8 2048 2
rpc_tasks 8 15 256 15
rpc_inode_cache 8 8 832 4
nf_conntrack_expect 0 0 240 16
nf_conntrack_ffffffff81b280e0 0 0 312 12
fib6_nodes 22 59 64 59
ip6_dst_cache 13 20 384 10
ndisc_cache 5 15 256 15
ip6_mrt_cache 0 0 128 30
RAWv6 67 70 1088 7
UDPLITEv6 0 0 1024 4
UDPv6 5 8 1024 4
.
.
.
.
size-64 8815 9499 64 59
size-32(DMA) 0 0 32 112
size-128 1650 1980 128 30
size-32 20444 20496 32 112
kmem_cache 190 190 32896 1
To Increase the width
Increase the width of the vmstat output terminal by using &ndash w option.
[root@linuxhelp Desktop]# vmstat -w
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 116104 76540 11176 202668 2 7 154 31 105 197 4 1 95 1 0
To display the time stamp
If you want to display the time stamp at vmstat output terminal, use option &ndash t with your vmstat command.
Example
[root@linuxhelp Desktop]# vmstat -t
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 116104 108952 11348 202700 2 6 152 30 105 198 4 1 95 1 0 2016-04-01 17:44:14 IST
To display all the fork system calls
Using option &ndash f with vmstat it displays all the fork system calls made by the system since the last boot.
[root@linuxhelp Desktop]# vmstat -f
6134 forks