博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
rh442 - Linux下性能监控命令vmstat的简单理解
阅读量:4177 次
发布时间:2019-05-26

本文共 2784 字,大约阅读时间需要 9 分钟。

以下解释都是通过man vmstat加上自己的一些理解得到的,每秒刷新一次监控数据可直接运行vmstat 1。

vmstat - Report virtual memory statistics

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.

FIELD DESCRIPTION FOR VM MODE

   Procs
       r: The number of runnable processes (running or waiting for run time). #正在运行或者等待cpu时间的进程数
       b: The number of processes in uninterruptible sleep. #等待非cpu资源(如磁盘io)的进程数
当r超过了cpu核心数时,表示cpu吃紧(md5sum /dev/zero);
当b大于0时,一般情况下表示有进程正在等待磁盘io(dd if=/dev/sda of=/dev/sda)。
   Memory
       swpd: the amount of virtual memory used.
       free: the amount of idle memory.
       buff: the amount of memory used as buffers. #用作缓存metadata(文件定义信息:inode等)的内存数
       cache: the amount of memory used as cache. #用作缓存文件内容的内存数
       inact: the amount of inactive memory.  (-a option)
       active: the amount of active memory.  (-a option)
一般没有指示性能优劣的作用。
   Swap
       si: Amount of memory swapped in from disk (/s). #每秒从磁盘(交换分区)读进内存的block数
       so: Amount of memory swapped to disk (/s). #每秒从内存写入磁盘(交换分区)的block数
反映了内存的使用情况,si或so一般为0或者极小,若si或so数值较大则表示物理内存吃紧,此时系统会很卡。
   IO
       bi: Blocks received from a block device (blocks/s). #每秒从磁盘读进内存的block数
       bo: Blocks sent to a block device (blocks/s). #每秒从内存写入磁盘的block数
反映了磁盘的繁忙情况,bi越高表示读操作越高(dd if=/dev/sda of=/dev/null),bo越高表示写操作越高(dd if=/dev/zero of=/tmp/bigfile bs=1M count=4000)。
   System
       in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.
暂时没发现其在性能指示方面的作用。
   CPU
       These are percentages of total CPU time.
       us: Time spent running non-kernel code.  (user time, including nice time)
       sy: Time spent running kernel code.  (system time)
       id: Time spent idle.  Prior to Linux 2.5.41, this includes IO-wait time. 
       wa: Time spent waiting for IO.  Prior to Linux 2.5.41, included in idle. #等待io的时间
       st: Time stolen from a virtual machine.  Prior to Linux 2.6.11, unknown. #虚拟机占用的cpu百分比
us + sy + id + wa + st = 100
CPU.wa一般与Procs.b/IO.bi/IO.bo正相关,值越大表示io越繁忙;
关于us和sy的区别摘抄了网上的一段话:
When operating on user data, a process (or thread) has limited access to
other processes, memory, devices, etc.  CPU used by such a thread is counted
as "user time".  If it needs to interact with the system, it makes a kernel
or system call (like read()).  When the call starts, it has to have extra
privileges, so it operates in kernel or system context.  Time accumulated by
the thread is counted as system time.
()

vmstat得知IO繁忙后怎么查出正在等待IO的进程及相应打开的文件:

ps aux | grep " D "
lsof | grep PROCESS_ID
The ongoing project of understanding load and bottle necks
http://current.workingdirectory.net/posts/2007/362/

关于使用top命令观察cpu负载的解释请参考下文:
rh442 - Linux下cpu使用率load average的简单理解

转载地址:http://ritai.baihongyu.com/

你可能感兴趣的文章
Logback及其MDC功能详解
查看>>
OpenStack4j访问OpenStack Q版本的Identity服务v2.0
查看>>
Java 11新特性
查看>>
Docker的网络类型及驱动器
查看>>
Docker容器支持IPv6的方法
查看>>
Can not deserialize instance of java.lang.String out of START_OBJECT token
查看>>
JTF的Unable to invoke request异常或Unable to find a MessageBodyReader of content-type application..异常详解
查看>>
JavaNCSS概述及JavaNCSS got an error while parsing the java file详解
查看>>
openssh-client amd64 1:7.2p2-4ubuntu2.4 404 Not Found
查看>>
Rapidoid及其容器化的Web平台
查看>>
JavaEE的JSON API规范JSON-P/JSON-B
查看>>
Kubernetes及其Master/Node节点
查看>>
OpenStack Heat简介
查看>>
Kubernetes集群内外的网络连通性
查看>>
TestNG中的@Factory与@DataProvider的执行比较
查看>>
TestNG中在一个test标签中的多个测试类之间共享中间数据的方法
查看>>
TestNG中在一个suite标签中的多个test标签之间共享中间数据的方法
查看>>
Docker容器实例的网络与通信
查看>>
OpenStack的Telemetry Data Collection服务概述
查看>>
iptables及其过滤规则
查看>>