1.vmstat -h 显示vmstat简要用法
$vmstat -husage: vmstat [-V] [-n] [delay [count]]
-V prints version.
-n causes the headers not to be reprinted regularly.
-a print inactive/active page stats.
-d prints disk statistics
-D prints disk table
-p prints disk partition statistics
-s prints vm table
-m prints slabinfo
-S unit size
delay is the delay between updates in seconds.
unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
count is the number of updates.
2.vmstat版本信息
$vmstat -Vprocps version 3.2.8
3.一些样例输出
VM mode (貌似这个用的最多)
$vmstat -a procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free inact active si so bi bo in cs us sy id wa
3 1 32 188264 2514408 3147980 0 0 269 974 733 1323 2 16 60 22
$vmstat -a 2 2
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free inact active si so bi bo in cs us sy id wa
0 0 48 195440 2516408 3138216 0 0 269 973 739 1331 2 16 60 22
0 0 48 195316 2516268 3138644 0 0 66 0 4857 6047 2 6 90 2
DISK MODE
$vmstat -ddisk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
ram0 0 0 0 0 0 0 0 0 0 0
ram1 0 0 0 0 0 0 0 0 0 0
ram2 0 0 0 0 0 0 0 0 0 0
ram3 0 0 0 0 0 0 0 0 0 0
ram4 0 0 0 0 0 0 0 0 0 0
ram5 0 0 0 0 0 0 0 0 0 0
ram6 0 0 0 0 0 0 0 0 0 0
ram7 0 0 0 0 0 0 0 0 0 0
ram8 0 0 0 0 0 0 0 0 0 0
ram9 0 0 0 0 0 0 0 0 0 0
ram10 0 0 0 0 0 0 0 0 0 0
ram11 0 0 0 0 0 0 0 0 0 0
ram12 0 0 0 0 0 0 0 0 0 0
ram13 0 0 0 0 0 0 0 0 0 0
ram14 0 0 0 0 0 0 0 0 0 0
ram15 0 0 0 0 0 0 0 0 0 0
loop0 0 0 0 0 0 0 0 0 0 0
loop1 0 0 0 0 0 0 0 0 0 0
loop2 0 0 0 0 0 0 0 0 0 0
loop3 0 0 0 0 0 0 0 0 0 0
loop4 0 0 0 0 0 0 0 0 0 0
loop5 0 0 0 0 0 0 0 0 0 0
loop6 0 0 0 0 0 0 0 0 0 0
loop7 0 0 0 0 0 0 0 0 0 0
sda 10893 20994 779038 155227 118692 477441 4769688 6803939 0 253
sr0 12 84 96 3264 0 0 0 0 0 3
sdb 141807 645 12702650 4720757 1158411 3778171 39499104 696352710 0 4694
sdc 32970 90 1441466 321611 265525 986736 10018792 76819593 0 719
DISK PARTITION MODE
$vmstat -p /dev/sda1sda1 reads read sectors writes requested writes
218 1214 0 0
SLAB MODE
$vmstat -mCache Num Total Size Pages
VMBlockInodeCache 1 1 4480 1
blockInfoCache 0 0 4160 1
AF_VMCI 0 0 704 11
fib6_nodes 12 113 32 113
ip6_dst_cache 14 30 256 15
ndisc_cache 2 20 192 20
RAWv6 5 11 704 11
UDPLITEv6 0 0 704 11
UDPv6 0 0 704 11
tw_sock_TCPv6 0 0 256 15
request_sock_TCPv6 0 0 128 30
TCPv6 4 6 1344 3
uhci_urb_priv 2 127 28 127
ext4_groupinfo_4k 17473 17501 104 37
flow_cache 0 0 80 48
ioat2 0 0 64 59
scsi_sense_cache 180 180 128 30
scsi_cmd_cache 160 160 192 20
sd_ext_cdb 2 113 32 113
scsi_tgt_cmd 0 0 48 78
cfq_io_context 173 236 64 59
cfq_queue 173 208 152 26
bsg_cmd 0 0 284 14
mqueue_inode_cache 1 7 576 7
udf_inode_cache 0 0 424 9
isofs_inode_cache 0 0 396 10
fat_inode_cache 0 0 424 9
fat_cache 0 0 20 169
hugetlbfs_inode_cache 1 10 368 10
squashfs_inode_cache 0 0 448 9
jbd2_journal_handle 79 169 20 169
jbd2_journal_head 486 567 60 63
jbd2_revoke_table 10 254 12 254
jbd2_revoke_record 0 0 32 113
journal_handle 0 0 20 169
journal_head 0 0 60 63
revoke_table 0 0 12 254
revoke_record 0 0 16 203
Cache Num Total Size Pages
ext4_inode_cache 3667 3900 644 6
ext4_xattr 0 0 48 78
ext4_free_data 0 0 36 101
ext4_allocation_context 4 35 112 35
ext4_prealloc_space 475 504 68 56
ext4_system_zone 0 0 24 145
ext4_io_end 0 0 572 7
ext4_io_page 0 0 8 339
ext3_inode_cache 0 0 532 7
ext3_xattr 0 0 48 78
configfs_dir_cache 0 0 52 72
dquot 0 0 192 20
kioctx 0 0 192 20
kiocb 0 0 128 30
inotify_event_private_data 0 0 16 203
inotify_inode_mark 207 250 76 50
dnotify_mark 0 0 76 50
dnotify_struct 0 0 20 169
fasync_cache 10 127 28 127
pid_namespace 0 0 40 92
nsproxy 0 0 24 145
posix_timers_cache 0 0 96 40
uid_cache 3 59 64 59
UNIX 437 448 512 8
ip_mrt_cache 0 0 128 30
UDP-Lite 0 0 576 7
tcp_bind_bucket 9 113 32 113
inet_peer_cache 0 0 64 59
secpath_cache 0 0 32 113
xfrm_dst_cache 0 0 320 12
ip_fib_alias 0 0 24 145
ip_fib_hash 22 84 44 84
ip_dst_cache 65 75 256 15
arp_cache 8 20 192 20
RAW 4 7 576 7
UDP 19 21 576 7
tw_sock_TCP 0 0 192 20
request_sock_TCP 0 0 128 30
Cache Num Total Size Pages
TCP 9 9 1216 3
eventpoll_pwq 16 202 36 101
eventpoll_epi 16 30 128 30
sgpool-128 2 2 3072 2
sgpool-64 2 5 1536 5
sgpool-32 4 10 768 5
sgpool-16 10 10 384 10
sgpool-8 160 160 192 20
scsi_data_buffer 0 0 20 169
blkdev_queue 28 32 944 4
blkdev_requests 284 380 208 19
blkdev_ioc 155 252 44 84
fsnotify_event_holder 0 0 12 254
fsnotify_event 1 59 64 59
bio-0 516 540 128 30
biovec-256 2 2 3072 2
biovec-128 0 0 1536 5
biovec-64 4 5 768 5
biovec-16 5 20 192 20
sock_inode_cache 495 495 448 9
skbuff_fclone_cache 63 63 448 9
skbuff_head_cache 159 200 192 20
file_lock_cache 30 78 100 39
shmem_inode_cache 2026 2048 464 8
Acpi-Operand 3024 3024 44 84
Acpi-ParseExt 7 78 48 78
Acpi-Parse 74 113 32 113
Acpi-State 84 84 44 84
Acpi-Namespace 1850 1885 24 145
task_delay_info 332 450 76 50
taskstats 15 24 328 12
proc_inode_cache 790 790 392 10
sigqueue 135 135 144 27
bdev_cache 22 28 512 7
sysfs_dir_cache 10699 10764 48 78
mnt_cache 28 40 192 20
filp 5940 6000 192 20
inode_cache 1742 2270 368 10
Cache Num Total Size Pages
dentry 8851 16385 132 29
names_cache 26 26 4096 1
key_jar 1 30 128 30
buffer_head 783486 883596 56 67
vm_area_struct 15799 15918 92 42
mm_struct 128 162 448 9
fs_cache 112 226 32 113
files_cache 113 195 256 15
signal_cache 167 252 640 6
sighand_cache 163 174 1344 3
task_xstate 332 336 512 8
task_struct 327 329 1072 7
cred_jar 591 1080 128 30
anon_vma_chain 8927 9425 24 145
anon_vma 5447 5684 16 203
pid 344 472 64 59
idr_layer_cache 635 676 148 26
radix_tree_node 38573 38584 296 13
size-4194304(DMA) 0 0 4194304 1
size-4194304 0 0 4194304 1
size-2097152(DMA) 0 0 2097152 1
size-2097152 0 0 2097152 1
size-1048576(DMA) 0 0 1048576 1
size-1048576 0 0 1048576 1
size-524288(DMA) 0 0 524288 1
size-524288 0 0 524288 1
size-262144(DMA) 0 0 262144 1
size-262144 0 0 262144 1
size-131072(DMA) 0 0 131072 1
size-131072 5 5 131072 1
size-65536(DMA) 0 0 65536 1
size-65536 0 0 65536 1
size-32768(DMA) 0 0 32768 1
size-32768 1 1 32768 1
size-16384(DMA) 0 0 16384 1
size-16384 283 287 16384 1
size-8192(DMA) 0 0 8192 1
size-8192 28 28 8192 1
Cache Num Total Size Pages
size-4096(DMA) 0 0 4096 1
size-4096 81 81 4096 1
size-2048(DMA) 0 0 2048 2
size-2048 224 224 2048 2
size-1024(DMA) 0 0 1024 4
size-1024 448 448 1024 4
size-512(DMA) 0 0 512 8
size-512 810 824 512 8
size-256(DMA) 0 0 256 15
size-256 360 360 256 15
size-192(DMA) 0 0 192 20
size-192 1366 1420 192 20
size-128(DMA) 0 0 128 30
size-128 1830 1830 128 30
size-64(DMA) 0 0 64 59
size-32(DMA) 0 0 32 113
size-64 4156 4661 64 59
size-32 12552 13786 32 113
kmem_cache 170 180 128 30
4.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]
vmstat [-d]
vmstat [-p disk partition]
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 average 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. --在internal时间段里,运行队列里等待CPU的任务(任务)的个数,即不包含vmstat进程 procs_running-1
b: The number of processes in uninterruptible sleep. --在internal时间段里,被资源阻塞的任务数(I/0,页面调度,等等),通常情况下是接近0的 procs_blocked
Memory
swpd: the amount of virtual memory used. --内存切换到swap的数量,单位KB.如果swpd的值不为0,或者比较大,比如超过了100m,只要si,so的值长期为0,系统性能还是正常的.
free: the amount of idle memory. --当前的空闲页面列表中内存数量,单位KB.
buff: the amount of memory used as buffers. --作为buffer cache的内存数量,一般对块设备的读写才需要缓冲.单位KB.
cache: the amount of memory used as cache. --作为page cache的内存数量,一般作为文件系统的cache.单位KB.如果cache较大,说明用到cache的文件较多,如果此时IO中bi比较小,说明文件系统效率比较好.
inact: the amount of inactive memory. (-a option) --不活动的内存数量,单位KB.
active: the amount of active memory. (-a option) --活动的内存数量,单位KB.
Swap
si: Amount of memory swapped in from disk (/s). --从磁盘交换到内存的交换页数量,单位KB/s.
so: Amount of memory swapped to disk (/s). --从内存交换到磁盘的交换页数量,单位KB/s.
IO
bi: Blocks received from a block device (blocks/s). --数据从块设备读取的量(读磁盘),单位blocks/s.
bo: Blocks sent to a block device (blocks/s). --数据写入块设备的量(写磁盘),单位blocks/s. 这里我们设置的bi+bo参考值为1000,如果超过1000,而且wa值较大应该考虑均衡磁盘负载,可以结合iostat输出来分析.
System
in: The number of interrupts per second, including the clock. --每秒的中断数,包括时钟中断. (不明白)
cs: The number of context switches per second. --在internal时间段里,每秒上下文切换的次数,即每秒内核任务交换的次数 ctxt/interval
CPU
These are percentages of total CPU time. --按总CPU时间的使用百分比来显示
us: Time spent running non-kernel code. (user time, including nice time) --cpu运行非kernel code所花费的时间百分比.(user time,including nice time 不明白).在internal时间段里,用户态的CPU时间(%),不包含 nice值为负进程 usr/total*100
sy: Time spent running kernel code. (system time) --cpu运行kernel code所花费的时间百分比.在internal时间段里,核心时间(%) (system + irq + softirq)/total*100
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. --cpu空闲百分比.在2.5.41内核以前,此值包含 IO-wait 时间.在internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间(%)idle/total*100
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. --cpu等待IO花费时间的百分比.此值被idle包含.在internal时间段里,硬盘IO等待时间(%)iowait/total*100
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown. --(不明白)
FIELD DESCRIPTION FOR DISK MODE
Reads
total: Total reads completed successfully
merged: grouped reads (resulting in one I/O)
sectors: Sectors read successfully
ms: milliseconds spent reading
Writes
total: Total writes completed successfully
merged: grouped writes (resulting in one I/O)
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
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
Fabian Frédérick
Throatwobbler Ginkgo Labs 27 July 1994 VMSTAT(8)
参考资料
vmstat工具 http://blog.sina.com.cn/s/blog_3dbab2840100j4fe.html (蓝)linux vmstat输出方法解析 http://www.jb51.net/os/RedHat/2161.html
Vmstat参数输出结果解释 http://www.agou.net/article/study/745.html