Understanding the vmstat Command in Linux with Examples

vmstat is a Linux system monitoring tool used to view the status of virtual memory, processes, CPU, IO, and other system metrics in real-time. Its full name is “virtual memory statistics.”Syntax: vmstat [options] [interval] [count], where the default output shows average statistics since system startup. Adding an interval (in seconds) refreshes the output in real-time, and the count specifies the number of outputs.procs: r (number of processes in the run queue, > number of CPU cores may indicate high load), b (number of blocked processes);memory: swpd (used swap memory), free (free memory), buff (buffer memory), cache (cached memory);swap: si (swap in, frequent occurrences are undesirable), so (swap out);io: bi (blocks read from devices, KB/s), bo (blocks written to devices);cpu: us (percentage of CPU in user mode), sy (system mode), id (idle), wa (IO wait, high values indicate IO bottlenecks).Common examples:1. vmstat 1 5: outputs once every second for a total of 5 times, providing real-time monitoring of system dynamics;2. vmstat -s: outputs a summary of memory statistics (total memory, free, cache, etc.);3. vmstat -d: views disk IO statistics (number of reads/writes, byte counts, etc.).

Leave a Comment