vmstat详解html
vmstat (virtual memory statistics)是一款类unix服务器性能的监控工具,他主要用来监控进程、内存、swap虚拟内存、块设备的输入输出,cpu的使用率等。vmstat应用于类unix系统。linux
首先咱们先在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 39908 313816 0 501136 4 6 21 10 38 55 0 0 99 1 0
再加上两个参数看看vmstat的输出。bash
[root@localhost ~]# vmstat 2 3 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 39908 313884 0 501140 4 6 21 10 38 55 0 0 99 1 0 0 0 39908 313924 0 501140 0 0 0 0 45 78 0 0 100 0 0 0 0 39908 313924 0 501140 0 0 0 0 41 76 0 0 100 0 0
这表示每隔两秒总共刷新三次。服务器
接下来再逐个分析每个字段表明的意思。app
你能够很清晰地看到vmstat总共监控6大块,分别为:进程(proc)、内存(memory)、虚拟内存(swap)、磁盘IO、系统相关(system)、cpu使用率。ide
r 即running,表示运行队列(就是说多少个进程真的分配到CPU)。工具
b 即block,表示阻塞队列。其实国外解释是:The number of processes in uninterruptible sleep.连续性睡眠的进程,你能够理解为阻塞队列。性能
swapd,表示虚拟内存的总共使用量。指定一个间隔时间,例如每隔3秒监测swapd的变化,若是swapd一直在增加,则表示虚拟内存正在被使用,这个信息告诉咱们当前系统的物理内存不足,这个时候,咱们就要分析内存不足的缘由,我一般是用top命令,再接着按M键,这样就会按内存使用率的大小将进程排序,由此分析占用内存较高的进程。spa
free,空闲物理内存的大小。
buff,内存中使用缓冲的总量。
cache,内存中使用缓存的总量。
si,即swamp in disk,每秒从磁盘读入虚拟内存的大小总量。Amount of memory swapped in from disk (per second).这个值大于0表示虚拟内存被使用,要注意内存泄露的问题。
so,swamp output to disk,即每秒从虚拟内存写入磁盘的大小总量。Amount of memory swapped to disk (per second).这个值大于0表示虚拟内存被使用,要注意内存泄露的问题。
bi,Blocks received from a block device (blocks per second),即每秒从块设备接收到的块设备量,即读块设备的量。
bo,Blocks sent to a block device (blocks/s),即每秒从块设备写入的块设备量,即写块设备的量。
in,即interrupts,cpu每秒中断的次数,包括时间中断。
cs,即content switch,上下文切换。上下文切换频繁会形成CPU没必要要的浪费。
us,即user time,用户CPU时间。
sy,即system time,即系统CPU时间。
id,即idle time,即CPU闲置时间。
wa,即wait time,等待IO时间,这个值太高,表示磁盘IO繁忙。
st,即stolen。偷取时间,与虚拟机相关。
参考连接:
[1]http://www.cnblogs.com/ggjucheng/archive/2012/01/05/2312625.html