vmstat,iostat,mpstat commands for (Performance Observation)
vmstat reports virtual memory statistics.
[root@li1250-113 ~]# yum provides */bin/vmstat
And install the package which is not there
[root@li1250-113 ~]# 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 Â 22948 Â 46884 Â 70964 229908 Â Â 0 Â Â 0 Â Â 0 Â Â 4 Â Â 5 Â Â 7 Â 0 Â 0 Â 99 Â 0 Â 0
vmstat output contains the following fields:
Procs – r: Total number of processes waiting to run
Procs – b: Total number of busy processes
Memory – swpd: Used virtual memory
Memory – free: Free virtual memory
Memory – buff: Memory used as buffers
Memory – cache: Memory used as cache.
Swap – si: Memory swapped from disk (for every second)
Swap – so: Memory swapped to disk (for every second)
IO – bi: Blocks in. i.e blocks received from device (for every second)
IO – bo: Blocks out. i.e blocks sent to the device (for every second)
System – in: Interrupts per second
System – cs: Context switches
CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time
Most important fields are free under memory and si, so under swap column.
Free – Amount of free/idle memory spaces.
si – Swaped in every second from disk in Kilo Bytes.
so – Swaped out every second to disk in Kilo Bytes.
[root@li1250-113 ~]# swapon -s
Filename Type Size Used Priority
/dev/xvdb                partition 524284 22948 -1
With this command, vmstat execute every two seconds and stop automatically after executing four intervals.
[root@li1250-113 ~]# vmstat 2 4
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 Â 22948 Â 46488 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 4 Â Â 5 Â Â 7 Â 0 Â 0 99 Â 0 Â 0
0 Â 0 Â 22948 Â 46488 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 32 Â 55 Â 0 Â 0 100 Â 0 Â 0
0 Â 0 Â 22948 Â 46488 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 20 Â 33 Â 57 Â 0 Â 0 100 Â 0 Â 0
0 Â 0 Â 22948 Â 46488 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 28 Â 51 Â 0 Â 0 100 Â 0 Â 0
vmstat command with -t parameter shows timestamps
[root@li1250-113 ~]# vmstat -t 2 4
procs ———–memory———- —swap– —–io—- -system– ——cpu—– —–timestamp—–
r  b  swpd  free  buff  cache  si  so   bi   bo  in  cs us sy id wa st         UTC
0 Â 0 Â 22948 Â 46512 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 4 Â Â 5 Â Â 7 Â 0 Â 0 99 Â 0 Â 0 2016-04-06 05:45:21
0 Â 0 Â 22948 Â 46512 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 33 Â 56 Â 0 Â 0 100 Â 0 Â 0 2016-04-06 05:45:23
0 Â 0 Â 22948 Â 46512 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 6 Â 33 Â 60 Â 0 Â 0 100 Â 0 Â 0 2016-04-06 05:45:25
0 Â 0 Â 22948 Â 46512 Â 71096 230276 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 28 Â 51 Â 0 Â 0 100 Â 0 Â 0 2016-04-06 05:45:27
vmstat command and -s switch displays summary of various event counters and memory statistics.
[root@li1250-113 ~]# vmstat -s
1011432 K total memory
964916 K used memory
440540 K active memory
388624 K inactive memory
46516 K free memory
71096 K buffer memory
230276 K swap cache
524284 K total swap
22948 K used swap
501336 K free swap
544464 non-nice user cpu ticks
330 nice user cpu ticks
1234286 system cpu ticks
279663968 idle cpu ticks
10433 IO-wait cpu ticks
0 IRQ cpu ticks
9257 softirq cpu ticks
18486 stolen cpu ticks
273130 pages paged in
11681720 pages paged out
187 pages swapped in
6304 pages swapped out
99407636 interrupts
191892591 CPU context switches
1457100549 boot time
5125032 forks
vmstat with -d option display all disks statistics.
[root@li1250-113 ~]# 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
ram10 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
ram11 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
ram12 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
ram13 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
ram14 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
ram15 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
loop0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
loop1 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
loop2 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
loop3 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
loop4 Â Â Â 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
loop7 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd1 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd2 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd3 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd4 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd5 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd6 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd7 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd8 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd9 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd10 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd11 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd12 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd13 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
disk- ————reads———— ————writes———– —–IO——
total merged sectors    ms  total merged sectors    ms   cur   sec
nbd14 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
nbd15 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
xvda  21710   220  543636   6323 1207952 1243942 23313512  187886    0   101
xvdb   162   120   2496    43   662  5642  50432   430    0    0
md0 Â Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0 Â Â Â 0
The vmstat displays in Megabytes with parameters -S and M(Uppercase & megabytes). By default vmstat displays statistics in kilobytes.
[root@li1250-113 ~]# vmstat -S M 1 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 Â Â 22 Â Â 45 Â Â 69 Â Â 224 Â Â 0 Â Â 0 Â Â 0 Â Â 4 Â Â 5 Â Â 7 Â 0 Â 0 99 Â 0 Â 0
0 Â 0 Â Â 22 Â Â 45 Â Â 69 Â Â 224 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 36 Â 59 Â 0 Â 0 100 Â 0 Â 0
0 Â 0 Â Â 22 Â Â 45 Â Â 69 Â Â 224 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 31 Â 53 Â 0 Â 0 100 Â 0 Â 0
0 Â 0 Â Â 22 Â Â 45 Â Â 69 Â Â 224 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 31 Â 55 Â 0 Â 0 100 Â 0 Â 0
0 Â 0 Â Â 22 Â Â 45 Â Â 69 Â Â 224 Â Â 0 Â Â 0 Â Â 0 Â Â 0 Â 31 Â 55 Â 0 Â 0 100 Â 0 Â 0
=====================================================================
iostat – Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
iostat reports CPU, disk I/O, and NFS statistics.
[root@li1250-113 ~]# iostat
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
Device:       tps   kB_read/s   kB_wrtn/s   kB_read   kB_wrtn
xvda        0.44     0.10     4.14   271570  11655192
xvdb        0.00     0.00     0.01    1248    25216
iostat with -c arguments displays only CPU statisticsÂ
[root@li1250-113 ~]# iostat -c
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
iostat with -d arguments displays only disks I/O statistics of all partitions
[root@li1250-113 ~]# iostat -d
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
Device:       tps   kB_read/s   kB_wrtn/s   kB_read   kB_wrtn
xvda        0.44     0.11     4.17   319278  11737988
xvdb        0.00     0.00     0.01    1248    27020
By default it displays statistics of all partitions, with -p and device name arguments displays only disks I/O statistics for specific device only
[root@li1250-113 ~]# iostat -p sda
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
Device:       tps   kB_read/s   kB_wrtn/s   kB_read   kB_wrtn
With -N (Uppercase) parameter displays only LVM statistics as shown.
[root@li1250-113 ~]# iostat -N
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
Device:       tps   kB_read/s   kB_wrtn/s   kB_read   kB_wrtn
xvda        0.44     0.11     4.17   320294  11743532
xvdb        0.00     0.00     0.01    2740    27020
With -V (Uppercase) parameter displays version of iostat as shown.
[root@li1250-113 ~]# iostat -V
sysstat version 10.1.5
(C) Sebastien Godard (sysstat <at> orange.fr)
By default iostat, displays the device I/O statistics in Blocks. To change it to MB, use -m as shown below.
[root@li1250-113 ~]# iostat -m
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
Device:       tps   MB_read/s   MB_wrtn/s   MB_read   MB_wrtn
xvda        0.44     0.00     0.00     312    11468
xvdb        0.00     0.00     0.00      2     26
[root@li1250-113 ~]# iostat -t
Linux 4.4.0-x86_64-linode63 (li1250-113.members.linode.com) Wednesday 06 April 2016 _x86_64_ (1 CPU)
Wednesday 06 April 2016 06:39:48 Â UTC
avg-cpu:  %user  %nice %system %iowait  %steal  %idle
0.19 Â Â 0.00 Â Â 0.44 Â Â 0.00 Â Â 0.01 Â 99.35
Device:       tps   kB_read/s   kB_wrtn/s   kB_read   kB_wrtn
xvda        0.44     0.11     4.17   320298  11744532
xvdb        0.00     0.00     0.01    2740    27020
