分享

vmstat命令详解

 快来看看咯 2020-04-16

一:简介#

vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可对操作系统的虚拟内存、进程、CPU活动进行监控。他是对系统的整体情况进行统计,不足之处是无法对某个进程进行深入分析

二:vmstat --help#

[root@centos ~]# vmstat --helpUsage: vmstat [options] [delay [count]] # delay:刷新时间间隔。如果不指定,只显示一条结果。 count:刷新次数。如果不指定刷新次数,但指定了刷新时间间隔,这时刷新次数为无穷。Options: -a, --active active/inactive memory # 显示活跃和非活跃内存 -f, --forks number of forks since boot # 显示从系统启动至今的fork数量 -m, --slabs slabinfo # 显示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 # 使用指定单位显示。参数有 k 、K 、m 、M ,分别代表1000、1024、1000000、1048576字节(byte)。默认单位为K(1024 bytes) -w, --wide wide output # 更宽的显示信息 -t, --timestamp show timestamp # 显示时间 -h, --help display this help and exit -V, --version output version information and exitFor more details see vmstat(8)

三:使用实例#

1:显示虚拟内存使用情况#

[root@centos ~]# vmstat 1 3procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 2  0      0  87288 150944 1311844    0    0     0    29    7    4  0  0 99  0  0 0  0      0  86124 150944 1311844    0    0     0     0  170  293  1  1 98  0  0 0  0      0  85100 150944 1311848    0    0     0    36  162  315  1  0 98  1  0

说明:

proces 进程:

r: 运行队列中进程数量

b: 等待IO的进程数量

memory内存:

swpd: 使用虚拟内存大小

free: 可用内存大小

buff: 用作缓冲的内存大小

cache: 用作缓存的内存大小

swap:

si: 每秒从交换区写到内存的大小

so: 每秒写入交换区的内存大小

IO:

bi: 每秒读取的块数

bo: 每秒写入的块数

system 系统:

in:每秒中断数,包括时钟中断

cs:每秒上下文切换数

cpu百分比表示:

us: 用户进程执行时间(user time)

sy: 系统进程执行时间(system time)

id: 空闲时间(包括IO等待时间),中央处理器的空闲时间 。以百分比表示。

wa: 等待IO时间

st:Steal time  虚拟 CPU 等待实际 CPU 的时间的百分比

2:显示活跃和非活跃内存#

[root@  centos ~]# vmstat -a 2 4procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free inact active si so bi bo in cs us sy id wa st 2 0 0 86852 570064 1024796 0 0 0 29 7 4 0 0 99 0 0 0 0 0 86836 570064 1024836 0 0 0 16 116 219 0 0 99 0 0 0 0 0 86836 570060 1024840 0 0 0 32 129 251 1 0 99 0 0 0 0 0 86820 570060 1024844 0 0 0 0 224 440 0 1 99 0 0

memory(内存):

inact: 非活跃内存大小(当使用-a选项时显示)

active: 活跃的内存大小(当使用-a选项时显示)

3:显示系统fork了多少次#

[root@centos ~]# vmstat -f      5259978 forks

 #

4:查看磁盘的读写#

[root@centos ~]# vmstat -d 2 4disk- ------------reads------------ ------------writes----------- -----IO------ total merged sectors ms total merged sectors ms cur secvda 148899 313 4046458 4895794 23837155 15874488 339477096 518529061 0 30209vda 148899 313 4046458 4895794 23837164 15874497 339477240 518529135 0 30209vda 148899 313 4046458 4895794 23837164 15874497 339477240 518529135 0 30209vda 148899 313 4046458 4895794 23837170 15874512 339477408 518529171 0 30209

说明:

这些信息主要来自于/proc/diskstats.

merged:表示一次来自于合并的写/读请求,一般系统会把多个连接/邻近的读/写请求合并到一起来操作.

5:查看某一磁盘的读写#

[root@centos ~]# vmstat -p /dev/vda1vda1          reads   read sectors  writes    requested writes              148813    4045074   23819688  339482408

说明:

这些信息主要来自于/proc/diskstats。

reads:来自于这个分区的读的次数。

read sectors:来自于这个分区的读扇区的次数。

writes:来自于这个分区的写的次数。

requested writes:来自于这个分区的写请求次数

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多