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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章