一. ubuntu14.04的man vmstat 描述:
NAME
vmstat - Report virtual memory statistics(報告虛拟記憶體統計資訊)
SYNOPSIS
vmstat [options] [delay [count]]
二. 常用法:
1). vmstat [delay] [count]
例如:vmstat 2 2表示監測間隔為2s, 監測次數為2次.
2). vmstat [delay]
例如:vmstat 2 表示間隔2s, 一直監測到結束vmstat.
輸出格式為:
三. 各個輸出項解釋:
Procs
r: The number of runnable processes (running or waiting for run time).
可運作程序的數目(正在運作或等待運作)[也就是在就緒隊列和運作隊列中的程序?]
當這個值超過了CPU數目,就會出現CPU瓶頸了。
b: The number of processes in uninterruptible sleep.
處于"不可中斷睡眠狀态"的程序數目.
[可中斷睡眠:可以用信号喚醒]
[不可中斷睡眠:不接受外來信号(異步信号).一般由IO引起,同步IO在做讀或寫操作時,cpu不能做其它事情,隻能等待,這時程序處于這種狀态,如果程式采用異步IO,這種狀态應該很少見]
Memory
swpd: the amount of virtual memory used.
以使用的虛拟記憶體.
free: the amount of idle memory.
空閑的實體記憶體[注意是實體記憶體].
buff: the amount of memory used as buffers.
被當做緩沖區的實體記憶體.
cache: the amount of memory used as cache.
被當做高速緩沖區的實體記憶體
inact: the amount of inactive memory. (-a option)
非活動的記憶體(-a選項)
active: the amount of active memory. (-a option)
活動的記憶體(-a選項)
Swap
si: Amount of memory swapped in from disk (/s).
每秒從磁盤讀入虛拟記憶體的大小,如果這個值大于0,表示實體記憶體不夠用或者記憶體洩露了.
so: Amount of memory swapped to disk (/s).
每秒虛拟記憶體寫入磁盤的大小,如果這個值大于0,表示實體記憶體不夠用或者記憶體洩露了.
IO
bi: Blocks received from a block device (blocks/s).
每秒從塊裝置接收到的塊數量(讀塊裝置),這裡的塊裝置是指系統上所有的磁盤和其他塊裝置,預設塊大小是1024byte.
bo: Blocks sent to a block device (blocks/s).
每秒向塊裝置發送的塊數量(寫塊裝置),例如讀取檔案,bo就要大于0。bi和bo一般都要接近0,不然就是IO過于頻繁,需要調整.
System
in: The number of interrupts per second, including the clock.
每秒鐘中斷次數,包括時鐘中斷.
cs: The number of context switches per second.
每秒上下文切換次數,例如我們調用系統函數,就要進行上下文切換,線程的切換,也要程序上下文切換,這個值要越小越好.上下文切換會影響CPU的使用率.
CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
使用者CPU時間,非核心代碼運作時間.
sy: Time spent running kernel code. (system time)
系統CPU時間,核心代碼運作時間.
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
空閑CPU時間.(在linux 2.5.41之前包括IO等待時間.)
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.
補充:
R (TASK_RUNNING),可執行狀态。
S (TASK_INTERRUPTIBLE),可中斷的睡眠狀态。
D (TASK_UNINTERRUPTIBLE),不可中斷的睡眠狀态。
一般由IO引起,同步IO在做讀或寫操作時,cpu不能做其它事情,隻能等待,這時程序處于這種狀态,如果程式采用異步IO,這種狀态應該很少見.
T (TASK_STOPPED or TASK_TRACED),暫停狀态或跟蹤狀态。
Z (TASK_DEAD – EXIT_ZOMBIE),退出狀态,程序成為僵屍程序。
X (TASK_DEAD – EXIT_DEAD),退出狀态,程序即将被銷毀。
O:程序正在處理器運作.
I:空閑狀态(idle)
B:程序正在等待更多的記憶體頁
四.vmstat的選項
-a, --active
Display active and inactive memory, given a 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.
-m, --slabs
Displays 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 ( or above required).
-D, --disk-sum
Report some summary statistics about disk activity.
-p, --partition device
Detailed statistics about partition ( or above required).
-S, --unit character
Switches outputs between (k), (K), (m), or (M) bytes.
Note this does not change the swap (si/so) or block(bi/bo) fields.