Operations 4 min read

Mastering vmstat: How to Monitor Linux Performance in Real Time

This guide explains how to use the Linux vmstat command to monitor system performance, detailing its output fields such as process states, memory, swap, I/O, system interrupts, and CPU usage, and shows how to interpret each metric for effective troubleshooting.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Mastering vmstat: How to Monitor Linux Performance in Real Time

vmstat is a comprehensive performance analysis tool that allows you to observe process states, memory usage, virtual memory, disk I/O, interrupts, context switches, and CPU usage.

Usage

Run vmstat without arguments to display the current system state, or provide parameters to set the sampling interval. For example, vmstat 2 1 collects server status every two seconds.

Sample Output

vmstat output example
vmstat output example

Explanation of Fields

(1) procs

r : Number of processes waiting to run. Values exceeding the number of CPUs indicate a CPU bottleneck; load >3 is high, >5 is very high, >10 is abnormal.

b : Number of blocked processes; higher values mean greater system pressure.

(2) memory

swpd : Amount of virtual memory used (KB). A value >0 indicates insufficient physical memory.

free : Size of free physical memory.

buff : Memory used for buffers such as directory contents and permissions.

cache : Memory used for file caching to improve performance; it is reclaimed quickly when applications need memory.

(3) swap

si : Kilobytes per second read from disk to swap; >0 suggests memory shortage or leak.

so : Kilobytes per second written from swap to disk.

(4) io

bi : Blocks received from a block device per second (default block size 1024 bytes).

bo : Blocks sent to a block device per second.

(5) system

in : Interrupts per second, including clock interrupts.

cs : Context switches per second; high values indicate excessive kernel transitions and should be minimized.

(6) cpu

us : User CPU usage percentage.

sy : System CPU usage percentage; high values may indicate heavy I/O or system calls.

id : Idle CPU percentage. Typically, id + us + sy = 100.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Performance MonitoringCPUMemorysystem metricsvmstat
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.