20 vmstat Commands Examples in Linux / UNIX | vmstat Commands Tutorials

vmstat-commands
vmstat – Report virtual memory statistics. vmstat is a tool that collects and reports data about your system’s memory, swap, and processor resource utilization in real time. It can be used to determine the root cause of performance and issues related to memory use.
vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.
Note:
iostat reports CPU, disk I/O, and NFS statistics.
vmstat reports virtual memory statistics.
mpstat reports processors statictics.
How to install vmstat?
1. Ensure you are logged in as ‘root’
‘iostat’ and ‘vmstat’ are apart of the ‘sysstat’ package and should be installed by default
2. Verify installation :
# rpm -qa | grep -i sysstat
3. Installation, if needed :
# rpm -ivh <name>
4. If you have connectivity to RHN or a Satellite Server:
# yum install sysstat
5. If you are using Ubantu:
# apt-get install sysstat
Example
1. The significant of the columns are explained in man page of vmstat in details. Most important fields are free under memory and si, so under swap column.
[root@tecmint ~]# vmstat -a
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 810420  97380  70628    0    0   115     4   89   79  1  6 90  3  0
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.
2. Execute vmstat ‘X’ seconds and (‘N’number of times). With this command, vmstat execute every two seconds and stop automatically after executing six intervals.
# vmstat 2 6
3. Vmstat with timestamps. vmstat command with -t parameter shows timestamps with every line printed as shown below.
# vmstat -t 1 5
4. Statistics of Various Counter, vmstat command and -s switch displays summary of various event counters and memory statistics.
$ vmstat -s
5. Disks Statistics, vmstat with -d option display all disks statistics.
$ vmstat -d
6. Display Statistics in Megabytes, The vmstat displays in Megabytes with parameters -S and M(Uppercase & megabytes). By default vmstat displays statistics in kilobytes.
# vmstat -S M 1 5
7. vmstat – Display number of forks since last boot, This displays all the fork system calls made by the system since the last boot. This displays all fork, vfork, and clone system call counts.
# vmstat -f
8. vmstat – Display slab info, Use option -m, to display the slab info as shown below.
# vmstat -m
Reference
The output of vmstat is displayed in a number of columns. The following sections provide brief overviews of the data reported in each column.
Procs
The procs data reports the number of processing jobs waiting to run and allows you to determine if there are processes “blocking” your system from running smoothly.
The r column displays the total number of processes waiting for access to the processor. The b column displays the total number of processes in a “sleep” state.
These values are often 0.
r: The number of processes waiting for run time.
b: The number of processes in uninterruptible sleep.
Memory
The information displayed in the memory section provides the same data about memory usage as the command free -m.
The swapd or “swapped” column reports how much memory has been swapped out to a swap file or disk. The free column reports the amount of unallocated memory. The buff or “buffers” column reports the amount of allocated memory in use. The cache column reports the amount of allocated memory that could be swapped to disk or unallocated if the resources are needed for another task.
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
The swap section reports the rate that memory is sent to or retrieved from the swap system. By reporting “swapping” separately from total disk activity, vmstat allows you to determine how much disk activity is related to the swap system.
The si column reports the amount of memory that is moved from swap to “real” memory per second. The so column reports the amount of memory that is moved to swap from “real” memory per second.
si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).
I/O
The io section reports the amount of input and output activity per second in terms of blocks read and blocks written.
The bi column reports the number of blocks received, or “blocks in”, from a disk per second. The bo column reports the number of blocks sent, or “blocks out”, to a disk per second.
bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).
System
The system section reports data that reflects the number of system operations per second.
The in column reports the number of system interrupts per second, including interrupts from system clock. The cs column reports the number of context switches that the system makes in order to process all tasks.
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.
CPU
The cpu section reports on the use of the system’s CPU resources. The columns in this section always add to 100 and reflect “percentage of available time”.
The us column reports the amount of time that the processor spends on userland tasks, or all non-kernel processes. The sy column reports the amount of time that the processor spends on kernel related tasks. The id column reports the amount of time that the processor spends idle. The wa column reports the amount of time that the processor spends waiting for IO operations to complete before being able to continue processing tasks.
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.
Field Description For Disk Mode
Reads
total: Total reads completed successfully
merged: grouped reads (resulting in one I/O)
sectors: Sectors read successfully
ms: milliseconds spent reading
Writes
total: Total writes completed successfully
merged: grouped writes (resulting in one I/O)
sectors: Sectors written successfully
ms: milliseconds spent writing
IO
cur: I/O in progress
s: seconds spent for I/O
Field Description For Disk Partition Mode
reads: Total number of reads issued to this partition
read sectors: Total read sectors for partition
writes : Total number of writes issued to this partition
requested writes: Total number of write requests made for partition
Field Description For Slab Mode
cache: Cache name
num: Number of currently active objects
total: Total number of available objects
size: Size of each object
pages: Number of pages with at least one active object
totpages: Total number of allocated pages
pslab: Number of pages per slab
Files
/proc/meminfo
/proc/stat
/proc/*/stat
Tagged : / / / / / / / / /

Linux Performance Monitoring using iostat, mpstat and vmstat | Linux Performance Monitoring Guide

linux-performance-monitoring

iostat reports CPU, disk I/O, and NFS statistics.

mpstat reports processors statictics.
vmstat reports virtual memory statistics.

vxstat – This Utility can be used as well.

iostat reports CPU, disk I/O, and NFS statistics.

The iostat command generates two types of reports, the CPU Utilization report and the Device Utilization report. The first report generated by the iostat command is the CPU Utilization Report.

iostat commands Table
iostat Iostat without any argument displays information about the CPU usage, and I/O statistics
iostat -c Display only cpu statistics
iostat -d Display only disk I/O statistics
iostat -n Display only network statistics (device and NFS statistics)
iostat -m Display the device I/O statistics in Blocks and To change I/O data in MB/second
iostat –p Display I/O statistics only for a device(data for all the disks available in the system)
iostat -t By default iostat displays only the current date. To display the current time, use this option
iostat -x Display extended disk I/O statistics information
iostat -x sda1 Display Extended status of device sda1
iostat 2 Execute Every 2 seconds (until you press Ctl-C)
iostat 2 3 To execute every 2 seconds for a total of 3 times
iostat -N To display the LVM statistics use option -N as shown below.
iostat –V To Display Version
iostat -d -x Display only disk I/O statisticsin in extended form
iostat -d -x sda Display only sda device I/O statisticsin in extended form
iostat -Td -xdn 5 For Solaris
iostat -d -x 5 For Linux
if Average read or write times over 50 ms, this should be consider for serious i/o problems

The report has the following format:

%user – Show the percentage of CPU utilization that occurred while executing at the user level (application).
%nice – provides statistics on a per physical device or partition basis.
Device – This column gives the device name
tps – Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device.
Blk_read/s – Indicate the amount of data read from the drive expressed in a number of blocks per second.
Blk_wrtn/s – Indicate the amount of data written to the drive expressed in a number of blocks per second.
Blk_read – The total number of blocks read.
Blk_wrtn – The total number of blocks written.
kB_read/s – Indicate the amount of data read from the drive expressed in kilobytes per second.
kB_wrtn/s – Indicate the amount of data written to the drive expressed in kilobytes per second.
wrqm/s – The number of write requests merged per second that were issued to the device.
r/s – The number of read requests that were issued to the device per second.
w/s – The number of write requests that were issued to the device per second.
rsec/s – The number of sectors read from the device per second.
wsec/s – The number of sectors written to the device per second.
await – The average time (in milliseconds) for I/O requests issued to the device to be served.
svctm – The average service time (in milliseconds) for I/O requests that were issued to the device.
%util – Percentage of CPU time during which I/O requests were issued to the device.

vmstat reports virtual memory statistics.

vmstat -a Display active and inactive memory
vmstat -f Display number of forks since last boot
vmstat 2 Execute Every x seconds (for y number of times)
vmstat -t 1 100 Display timestamp
vmstat -V version info
vmstat -m Display slab info
vmstat -s Display statistics in a table format
vmstat -d Use option -d to display the disk statistics as shown below. This displays the reads, writes, and I/O statistics of the disk.
vmstat 1 3 vmstat – Increase the width of the display
vmstat -p sdb1 Display statistics for a partition
vmstat -S m Display in MB

The report has the following format:

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

mpstat reports processors statictics.

reports processors statictics(mpstat – Report processors related statistics and mpstat displays CPU statistics )

mpstat :- mpstat displays CPU statistics
mpstat -A :- Display all information
mpstat -P ALL :- Display CPU statistics of individual CPU (or) Core

Reference:
http://www.linux-tutorial.info/modules.php?name=ManPage&sec=1&manpage=iostat
http://www.thegeekstuff.com/2011/07/iostat-vmstat-mpstat-examples/

Tagged : / / / / / / / / / / / / / / / / / / /