vmstat 中文详解

[root@ljj procps-3.2.7]# man vmstat
VMSTAT(8) Linux Administrator‘s Manual VMSTAT(8)

NAME
vmstat – Report virtual memory statistics

SYNOPSIS
vmstat [-a] [-n] [delay [ count]]
vmstat [-f] [-s] [-m]
vmstat [-S unit] 指定显示的数字的单位(默认为K) 如: vmstat -S M 1 5
vmstat [-d]
vmstat [-p disk partition] 显示指定分区的信息 如: vmstat -p sda1
vmstat [-V]

DESCRIPTION
vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.

The first report produced gives averages since the last reboot. Additional reports give information on a sampling
period of length delay. The process and memory reports are instantaneous in either case.

Options
The -a switch displays active/inactive memory, given a 2.5.41 kernel or better.

The -f switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and
is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on
thread usage. This display does not repeat.

The -m displays slabinfo.

The -n switch causes the header to be displayed only once rather than periodically.

The -s switch displays a table of various event counters and memory statistics. This display does not repeat.

delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the aver-
age values since boot.

count is the number of updates. If no count is specified and delay is defined, count defaults to infinity.

The -d reports disk statistics (2.5.70 or above required)

The -p followed by some partition name for detailed statistics (2.5.70 or above required)

The -S followed by k or K or m or M switches outputs between 1000, 1024, 1000000, or 1048576 bytes

The -V switch results in displaying version information.

FIELD DESCRIPTION FOR VM MODE
Procs
r: The number of processes waiting for run time. 可执行队列里的进程个数
b: The number of processes in uninterruptible sleep. 深度睡眠的进程个数(等待资源但不可中断)

Memory
swpd: the amount of virtual memory used. 使用的虚拟内存的数量(太大说明可能物理内存不足)
free: the amount of idle memory. 空闲的内存数量(太大则浪费,太小则为内存不足)
buff: the amount of memory used as buffers. 用做buffer的内存数量(不知道怎么解释)
cache: the amount of memory used as cache. 用做cache的内存数量(不知道怎么解释)
inact: the amount of inactive memory. (-a option) 不活动的内存数量(使用-a选项才显示)(不知道怎么解释)
active: the amount of active memory. (-a option) 活动的内存数量(使用-a选项才显示)(不知道怎么解释)

Swap (这两个值都不应该太大,最好为0,基本上不要拿硬盘当内存用)
si: Amount of memory swapped in from disk (/s). 每秒从交换内存调入内存的数量
so: Amount of memory swapped to disk (/s). 每秒写入交换内存的数量

IO
bi: Blocks received from a block device (blocks/s). 每秒从设备读入内存的数量
bo: Blocks sent to a block device (blocks/s). 每秒从内存写入设备的数量

System (这里我解释不清楚)
in: The number of interrupts per second, including the clock. 每秒钟cpu中断的次数
cs: The number of context switches per second. cpu每秒钟时间片的切换次数(异步io可能会导致切换频繁,关于同步io与异步io,一般来讲,大数据量的io适合使用异步io,非常小的数据量的io考虑使用同步io

CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time) cpu 执行非内核代码花费的时间
sy: Time spent running kernel code. (system time) cpu执行内核代码花费的时间
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. cpu空闲时间
wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero. cpu等待io的时间,(如果该值与id成反比,说明基本是同步io,这时,如果该值总是很大的话,io就是瓶颈,可以考虑使用异步io)

FIELD DESCRIPTION FOR DISK MODE
Reads
total: Total reads completed successfully 共读了多少次
merged: grouped reads (resulting in one I/O) 分了多少组(多次io可能合并为一组来读取)
sectors: Sectors read successfully 读的扇区的数目
ms: milliseconds spent reading 读数据花费的毫秒数

Writes
total: Total writes completed successfully 共写了多少次
merged: grouped writes (resulting in one I/O) 分了多少组(多次io可能合并为一组来写)
sectors: Sectors written successfully 写扇区的数目
ms: milliseconds spent writing 写数据花费的毫秒数

IO
cur: I/O in progress
s: seconds spent for I/O

FIELD DESCRIPTION FOR DISK PARTITION MODE 使用 -p 选项时显示的信息
reads: Total number of reads issued to this partition 读该分区的次数
read sectors: Total read sectors for partition 从该分区读取的扇区数
writes : Total number of writes issued to this partition 写入该扇区的扇区数
requested writes: Total number of write requests made for partition 对该分区的写请求次数

FIELD DESCRIPTION FOR SLAB MODE
cache: Cache name
num: Number of currently active objects
total: Total number of available objects
size: Size of each object
pages: Number of pages with at least one active object
totpages: Total number of allocated pages
pslab: Number of pages per slab

NOTES
vmstat does not require special permissions.

These reports are intended to help identify system bottlenecks. Linux vmstat does not count itself as a running
process.

All linux blocks are currently 1024 bytes. Old kernels may report blocks as 512 bytes, 2048 bytes, or 4096 bytes.

Since procps 3.1.9, vmstat lets you choose units (k, K, m, M) default is K (1024 bytes) in the default mode

vmstat uses slabinfo 1.1 FIXME

FILES
/proc/meminfo
/proc/stat
/proc/*/stat

SEE ALSO
iostat(1), sar(1), mpstat(1), ps(1), top(1), free(1)

BUGS
Does not tabulate the block io per device or count the number of system calls.

AUTHORS
Written by Henry Ware <al172@yfn.ysu.edu>.
Fabian Fr<A8><A6>d<A8><A6>rick <ffrederick@users.sourceforge.net> (diskstat, slab, partitions…)

Throatwobbler Ginkgo Labs 27 July 1994 VMSTAT(8)
(END)

 

附:实例

1.

[junjie2@localhost ~]$ vmstat -S M 1 8
procs ———–memory———- —swap– —–io—- –system– —-cpu—-
r b swpd free buff cache si so bi bo in cs us sy id wa
0 1 8 14 662 134 0 0 0 0 0 0 0 0 85 14
0 1 8 14 663 134 0 0 240 296 1313 460 1 0 76 24
0 0 8 14 663 134 0 0 196 36 1316 464 0 1 84 14
0 2 8 15 662 134 0 0 240 172 1339 494 0 1 81 19
0 2 8 14 662 135 0 0 376 148 1426 625 1 1 71 29
0 2 8 14 663 134 0 0 372 240 1357 537 0 1 66 34
0 1 8 15 662 134 0 0 224 692 1318 458 1 1 66 33
0 0 8 15 662 134 0 0 292 284 1441 605 0 1 55 44

根据id和wa列来看,应该多采用的io为同步io,而且在io上存在一些瓶颈

 

2.

留下评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据