关于vmstat命令的使用详解1.0

Vmstat命令详解

一、前言

vmstat命令:用来查看并获取进程,虚拟内存,页面交换空间以及CPU活动状况的信息,综合这些信息可以分析系统当前的负载情况。

二、使用vmstat

1、用法

   vmstat - Report virtual memory statistics

   -a, --active
          Display active and  inactive memory, given a 2.5.41 kernel or better.
		  显示活跃和非活跃内存
   -f, --forks
          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.
		  显示从系统启动至今的fork数量
   -m, --slabs
          Displays slabinfo.
		  显示slabinfo
   -n, --one-header
          Display the header only once rather than periodically.
		  只在开始时显示一次各字段名称
   -s, --stats
          Displays  a table of various event counters and memory statistics.  This display
          does not repeat.
		  显示内存相关统计信息及多种系统活动数量
   -d, --disk
          Report disk statistics (2.5.70 or above required).
		  显示磁盘相关统计信息
   -D, --disk-sum
          Report some summary statistics about disk activity.
		  报告一些关于磁盘活动的汇总统计信息
   -p, --partition device
          Detailed statistics about partition (2.5.70 or above required).
		  显示指定磁盘分区统计信息
   -S, --unit character
          Switches outputs between 1000 (k), 1024 (K), 1000000 (m), or 1048576 (M)  bytes.
          Note this does not change the swap (si/so) or block (bi/bo) fields.
		  使用指定单位显示。参数有 k 、K 、m 、M ,分别代表1000、1024、1000000、1048576字节(byte)。默认单位为K(1024 bytes)
   -t, --timestamp
          Append timestamp to each line
		  向每一行追加时间戳
   -w, --wide
          Wide  output  mode  (useful  for systems with higher amount of memory, where the
          default output mode suffers from unwanted column breakage).  The output is wider
          than 80 characters per line.
		  宽输出模式(适用于内存较大的系统,默认输出模式会导致不希望的列中断)。输出的宽度超过每行80个字符
   -V, --version
          Display version information and exit.
		  显示版本信息
   -h, --help
          Display help and exit.

2、各部分的含义

名称标志说明
Procs:进程r: The number of runnable processes。等待执行的任务数展示了正在执行和等待cpu资源的任务个数。当这个值超过了cpu个数,就会出现cpu瓶颈
b: The number of processes in uninterruptible sleep.等待IO的进程数量这列的值如果长时间大于1,则需要进行关注了
名称标志说明
Memory:内存swpd: the amount of virtual memory used.正在使用虚拟的内存大小,单位k
free: the amount of idle memory.空闲内存大小
buff: the amount of memory used as buffers.已用的buff大小,对块设备的读写进行缓冲即将写入磁盘的缓冲大小
cache: the amount of memory used as cache.已用的cache大小,文件系统的cache从磁盘中读取的缓存大小
inact: the amount of inactive memory. (-a option)非活跃内存大小,即被标明可回收的内存,区别于free和active
active: the amount of active memory. (-a option)活跃的内存大小
名称标志说明
Swapsi: Amount of memory swapped in from disk (/s).每秒从交换区写入内存的大小(单位:kb/s)由内存进入交换区的数量
so: Amount of memory swapped to disk (/s).每秒从内存写到交换区的大小由交换区进入内存的数量
名称标志说明
IObi: Blocks received from a block device (blocks/s).每秒读取的块数(读磁盘)从块设备读取数据的量(读磁盘)
bo: Blocks sent to a block device (blocks/s). 每秒写入的块数(写磁盘)从块设备写入数据的量(写磁盘)
名称标志说明
Systemin: The number of interrupts per second, including the clock. 每秒中断数,包括时钟中断表示在某一时间间隔中观测到的每秒设备中断数
cs: The number of context switches per second. 每秒上下文切换数表示每秒产生的上下文切换次数
名称标志说明
CPUus: Time spent running non-kernel code.用户进程执行消耗cpu时间(user time)us的值比较高时,说明用户进程消耗的cpu时间多,但是如果长期超过50%的使用,那么我们就该考虑优化程序算法或其他措施了
sy: Time spent running kernel code. 系统进程消耗cpu时间(system time)sys的值过高时,说明系统内核消耗的cpu资源多,这个不是良性的表现,我们应该检查原因。
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.空闲时间(包括IO等待时间)
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.等待IO时间Wa过高时,说明io等待比较严重,这可能是由于磁盘大量随机访问造成的,也有可能是磁盘的带宽出现瓶颈。
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.从虚拟机窃取的时间一般都为0,不用关注

三、具体应用场景

1、第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数

vmstat 3 3

运行结果:
在这里插入图片描述每3秒进行一次采样,总计三次

2、vmstat每3秒采集数据,一直采集,直到结束程序

vmstat 3

运行结果:
在这里插入图片描述持续进行采样,每三秒一次,直到手动结束程序

注:个人学习文档,侵权请联系删除

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深度学习0407

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值