rh442 - Linux下性能监控命令vmstat的简单理解

以下解释都是通过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.
( http://www.loveunix.net/thread-91630-1-1.html )

关于使用top命令观察cpu负载的解释请参考下文:
rh442 - Linux下cpu使用率load average的简单理解
http://blog.csdn.net/t0nsha/article/details/8604089

本文转载自t0nsha's Blog,原文链接:http://blog.csdn.net/t0nsha/article/details/9005176

你可能感兴趣的:(linux,内存,系统,等待)