The vmstat tool reports statistics about processes, memory, paging, I/O, traps, disks and CPU activity.
Executing it without any arguments shows us a concurrent snapshot of system performance:
root:/tmp> vmstat 5 3
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 4624068 113576 8919936 0 0 20 179 84 28 6 2 92 1 0
0 0 0 4633708 113576 8909304 0 0 0 1433 192 522 0 0 100 0 0
0 0 0 4633660 113576 8909388 0 0 0 255 472 732 0 0 100 0 0
-
r number of processes running or runnable
b number of processes in uninterruptible sleep
swpd virtual memory used in bytes
free free memory in bytes
buff buffer memory in bytes
cache cache memory for filesystems
si average swapins or writes to swap per second in Kbytes (RAM → disk)
so average swapouts or reads from swap per second in Kbytes (disk → RAM)
bi average blocks read from block devices per second
bo average blocks written to block devices per second
in average interrupts per second
cs average context switches per second
us average CPU utilisation in user mode
sy average CPU utilisation in system mode
id average idle CPU
wa average CPU waiting on I/O
st average CPU used by other VMs or the host (applies only to VMs)
We can get a slightly less cluttered output with the -w flag and -S M switches from Kb to Mb:
root:/tmp> vmstat -w -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 4318 112 8778 0 0 20 179 84 28 6 2 92 1 0
With the -a flag we can flip buff & cache into inact & active memory:
root:/tmp> vmstat -a 5 2
procs ———– memory————— –swap— —io– -system- —–cpu——
r b swpd free inact active si so bi bo in cs us sy id wa st
1 0 0 4498464 3192532 7242808 0 0 19 173 83 33 5 2 92 1 0
0 0 0 4498200 3192588 7243532 0 0 0 12 171 411 0 0 99 0 0
With the -f flag we get the figure of total number of forks + vforks + clone system calls since boot:
root:/tmp> vmstat -f
129189 forks
With the -m flag we get a list of all the kernel memory slabs:
root:/tmp> vmstat -m
Cache Num Total Size Pages
nf_conntrack_ffff880431750000 0 0 320 25
nf_conntrack_ffff880091db91c0 0 0 320 25
fuse_inode 1 23 704 23
nf_conntrack_ffff880091db8000 0 0 320 25
nf_conntrack_ffffffff81cfa400 658 700 320 25
ext4_groupinfo_4k 252 252 144 28
fat_inode_cache 11 46 688 23
fat_cache 0 0 40 102
kvm_vcpu 0 6 16384 2
[…]
The -s flag shows us the same figures of previous flags in a different one-off format:
root:/tmp> vmstat -s
16201988 K total memory
2683036 K used memory
7301728 K active memory
3209868 K inactive memory
4421444 K free memory
114724 K buffer memory
8982784 K swap cache
3999740 K total swap
0 K used swap
3999740 K free swap
1684736 nonnice user cpu ticks
217885 nice user cpu ticks
536715 system cpu ticks
32872359 idle cpu ticks
326992 IOwait cpu ticks
26 IRQ cpu ticks
1582 softirq cpu ticks
0 stolen cpu ticks
6628262 pages paged in
60490033 pages paged out
0 pages swapped in
0 pages swapped out
115331205 interrupts
312863818 CPU context switches
1444919942 boot time
129745 forks
The -d flag shows us some total statistics of reads/writes per disk:
root:/tmp> vmstat -d
disk- —————reads—————— ———–writes————– ——IO———
total merged sectors ms total merged sectors ms cur sec
sda 342254 6168 9459537 2016797 3200081 128768 109738556 56844920 0 13650
sr0 0 0 0 0 0 0 0 0 0 0
sdb 79589 4663 3806412 1728959 3254500 175681 118347524 96477158 0 22851
md127 366413 0 9114163 0 3051045 0 107043376 0 0 0
dm0 31579 0 2152489 555565 18105 0 342872 2709175 0 574
dm1 46304 0 2433034 249343 35824 0 1950200 2643780 0 343
dm2 867 0 96306 13302 562 0 12736 12153 0 20
dm3 978 0 23442 13081 165 0 9288 3240 0 14
dm4 3344 0 61954 28003 3045 0 2517928 6861239 0 39
dm5 750 0 27186 20155 499 0 10760 18538 0 23
dm6 672 0 36090 15636 190 0 10544 6312 0 18
dm7 391 0 25450 10794 135 0 9752 6279 0 15
dm8 316 0 13778 5638 33 0 8392 954 0 6
dm9 1204 0 24346 16145 227 0 8472 4790 0 20
dm10 10969 0 1391586 347714 20453 0 300520 528149 0 422
dm16 21371 0 1508369 161045 194673 0 8201432 27176670 0 2390
dm17 313357 0 5452457 2507772 2715906 0 98499072 132863281 0 19222
The -D flag shows disk and I/O statistics in the same fashion as -s:
root:/tmp> vmstat -D
17 disks
7 partitions
1220412 total reads
10847 merged reads
35635383 read sectors
7690086 milli reading
12496876 writes
304567 merged writes
447036536 written sectors
326177068 milli writing
0 inprogress IO
59624 milli spent IO
The flag -p shows us statistics at the partition level: