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.
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
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
The output of vmstat is displayed in a number of columns. The following sections provide brief overviews of the data reported in each column.
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.
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)
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).
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).
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.
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
total: Total reads completed successfully
merged: grouped reads (resulting in one I/O)
sectors: Sectors read successfully
ms: milliseconds spent reading
total: Total writes completed successfully
merged: grouped writes (resulting in one I/O)
sectors: Sectors written successfully
ms: milliseconds spent writing
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
Latest posts by Rajesh Kumar (see all)
- What is Xray in Jira? - April 9, 2021
- How to build jobs in jenkins when a change is pushed to Bitbucket - April 8, 2021
- How to trigger a jenkins job when code is pushed to github using “GitHub hook trigger for GITScm polling” - April 8, 2021