root@vgt-ubuntu-10:~# vmstat -h
Usage:
vmstat [options] [delay [count]]
Options:
-a, --active active/inactive memory
-f, --forks number of forks since boot
-m, --slabs slabinfo
-n, --one-header do not redisplay header
-s, --stats event counter statistics
-d, --disk disk statistics
-D, --disk-sum summarize disk statistics
-p, --partition <dev> partition specific statistics
-S, --unit <char> define display unit
-w, --wide wide output
-t, --timestamp show timestamp
-h, --help display this help and exit
-V, --version output version information and exit
For more details see vmstat(8).
3. 常用选项
-s:显示内存统计的详细信息(以表格形式)。
-n:只显示一次表头(默认每次刷新都会显示表头)。
-a:显示活跃和非活跃内存(active/inactive memory)。
-d:显示磁盘统计信息。
-w:以更宽的格式输出,便于阅读。
-t:在输出中添加时间戳。
4. 使用示例
1:基本使用
1
vmstat
输出示例(Linux 系统):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 123456 78901 234567 0 0 10 20 100 200 5 2 92 1 0
字段解释(部分关键字段):
procs:进程相关。
r:等待运行的进程数。
b:处于不可中断睡眠状态的进程数。
memory:内存信息(单位通常为 KB)。
swpd:使用的交换分区大小。
free:空闲内存。
buff:用作缓冲的内存(写缓存)。
cache:用作缓存的内存(读缓存)。
swap:交换分区使用情况。
si:从交换分区换入内存的数据量。
so:从内存换出到交换分区的数据量。
io:I/O 统计。
bi:从块设备读取的数据量。
bo:写入块设备的数据量。
system:系统活动。
in:每秒中断数。
cs:每秒上下文切换数。
cpu:CPU 使用百分比。
us:用户时间。
sy:系统时间。
id:空闲时间。
wa:等待 I/O 的时间。
2:实时监控
1
vmstat 2 5
每 2 秒刷新一次,共刷新 5 次。
3:显示详细内存统计
1
vmstat -s
输出示例:
16384000 total memory
12345678 used memory
2345678 active memory
3456789 inactive memory
4038322 free memory
789012 buffer memory
2345678 swap cache
16777216 total swap
0 used swap
16777216 free swap