System Monitoring : vmstat

vmstat

Like iostat, vmstat is part of the sysstat package. You can run the command by itself:

vmstat

and get a display of active and inactive memory:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 1826368 57028 102352 0 0 1 1 251 6 0 0 100 0

Notice that you’re given sections for memory (RAM), swap (virtual memory on disk), I/O, in-memory and in-swap system memory, and CPU usage. Now run the command:

vmstat 1 5

for five reports at one-second intervals:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 1826368 57028 102352 0 0 1 1 251 6 0 0 100 0
0 0 0 1826368 57028 102352 0 0 0 0 1008 13 0 0 100 0
0 0 0 1826368 57028 102352 0 0 0 0 1004 13 0 0 100 0
0 0 0 1826368 57036 102344 0 0 0 60 1007 25 0 0 100 0
0 0 0 1826368 57036 102344 0 0 0 0 1004 13 0 0 100 0

procs
memory
swap
io
system
cpu
r
b
swpd
free
buff
cache
si
so
bi
bo
in
cs
us
sy
id
wa
# processes waiting to be run # sleeping processes used swap in K free RAM RAM used for buffers in K RAM used as system cache K/s swapped in K/s swapped out blocks/s sent to block devices blocks/s received from block devices interrupts/s sent to CPU context changes/s sent to CPU CPU user time CPU system time CPU idle time CPU wait time for I/O

If you don’t have enough swap space, you’ll see it here as excessive swap-in and swap-out.

If you don’t have enough RAM, you’ll see too little free memory.

If you’ve got too slow a CPU, the last column will show you too much waiting going on.

And if system processes are hogging memory, you’ll see too little free memory.

 

free

A related utility is the free command.  It displays total RAM and swap memory in Kilobytes (K), and the amount actually in use.

 
total
used
free
shared
buffers
cached
Mem: total RAM RAM in use free RAM shared memory requests from hardware devices reserved by the kernel
-/+ buffers/cache:
 
RAM minus buffers
RAM minus cache
     
Swap: Swap file/partition size Amount of swap used Free swap space