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.
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
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
