vmstat Command

The vmstat (virtual memory statistics) command in Linux is used to report information about processes, memory, paging, block IO, traps, and CPU activity. It's a valuable tool for system administrators to monitor system performance and identify bottlenecks.

Syntax

vmstat [options] [delay [count]]

Description

vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The first report produced gives statistics since the last reboot. Subsequent reports give statistics collected at a variable time interval.

Common uses include:

  • Monitor system performance
  • Identify memory bottlenecks
  • Analyze CPU utilization
  • Track I/O activity

Common Options

Option Description
-a, --active Display active/inactive memory
-f, --forks Display number of forks since boot
-m, --slab Display slabinfo
-s, --stats Display a table of various event counters and memory statistics
-d, --disk Report disk statistics
-p, --partition Report disk statistics for a specific partition
-S unit, --unit unit Specify unit of display for memory (k, M, G, T)

Examples

Display a single report

vmstat

Displays a single report of virtual memory statistics since the last reboot.

Monitor continuously every 3 seconds

vmstat 3

Provides continuous reports every 3 seconds until interrupted (Ctrl+C).

Monitor 5 times every 2 seconds

vmstat 2 5

Provides 5 reports, each 2 seconds apart.

Display active/inactive memory

vmstat -a

Shows active and inactive memory in the memory section.

Display disk statistics

vmstat -d

Reports statistics for each disk.

See also