commands

vmstat — Inspect virtual memory and CPU statistics

Report runnable and blocked tasks, memory, swap and CPU statistics; first CPU rates are since boot. Use a fresh private workspace; No production workload is required.

Formal Syntax & Structure

linux syntaxlinux
vmstat [delay [count]]

Parameters & Attributes

NameTypeDescription
delayoperandSeconds between samples
countoperandNumber of reports

Return Value

exit status and output

Prints sampled virtual-memory and activity counters. A successful bounded run reports samples, not a diagnosis; distinguish the initial since-boot report from later interval samples.

Working Example

Example Snippetlinux
vmstat 1 2 | awk 'NR==2 {for(i=1;i<=NF;i++) if($i=="r") r=1; if(r) print "r column present"}'
Linux Reference