資訊人筆記

Work hard, Have fun, Make history!

使用者工具

網站工具


operating_system:useful_command:nix_vmstat_command

[*nix] Resources Monitor: vmstat command

0x00 前言

除了前面介紹的 [*nix] Resources Monitor: Top Command 之外

vmstat 也是 *nix 上一個對資源監控的指令

按照 man page 的說法: Report virtual memory statistics

它主要呈現的是虛擬記憶體的相關統計數據


0x01 vmstat command overview

FreeBSD:

Ubuntu:

兩個系統輸出的欄位有些許不同,底下我們個別說明


0x02 vmstat on FreeBSD

procs

Information about the numbers of processes in various states.

簡單說,這個區塊顯示了不同狀態的 process 的統計數量

  • r: 在 run queue 中的 process 數量
  • b: blocked for resources 的 process 數量,像是 i/o, paging 等
  • w: runnable or short sleeper (< 20 secs) but swapped

memory

這區則是關於 virtual memory 與 real memory 的使用情況

  • avm: active virtual pages,memory virtual pages 視為 active 的條件為: 這個分頁的記憶體所屬的 process,在過去 20 mins 內有 active
  • fre: size of the free list

page

關於 page faults 和 paging activity 的訊息

  • flt: total number of page faults
  • re: page reclaims (simulating reference bits)
  • pi: pages paged in
  • po: pages paged out
  • fr: pages freed per second
  • sr: pages scanned by clock algorithm, per-second

disks

Disk operations per second (this field is system dependent).

每秒的磁碟操作次數

這個欄位名稱是由 disk name 的前兩字母和識別數字組成

如果有兩個以上的 disk device 預設顯示是兩個 disks,除了用 -n 參數另外下

faults

Trap/interrupt rate averages per second over last 5 seconds.

  • in: device interrupts per interval (including clock interrupts)
  • sy: system calls per interval
  • cs: cpu context switch rate (switches/interval)

cpu

Breakdown of percentage usage of CPU time.

  • us: user time for normal and low priority processes
  • sy: system time
  • id: cpu idle

0x03 vmstat on Ubuntu

Procs

  • r: The number of runnable processes (running or waiting for run time).
  • b: The number of processes in uninterruptible sleep.

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.

Swap

  • si: Amount of memory swapped in from disk (/s).
  • so: Amount of memory swapped to disk (/s).

IO

  • bi: Blocks received from a block device (blocks/s).
  • bo: Blocks sent to a block device (blocks/s).

System

  • in: The number of interrupts per second, including the clock.
  • cs: The number of context switches per second.

CPU

這一區基本上跟 top command 看到的那幾個欄位是一樣的

  • us: 運行在 user space 的 processes 所佔用的 CPU time 比例
  • sy: kernel space 的 processes 所佔用的 CPU time 比例
  • id: 閒置的 CPU 比例
  • wa: 等待 IO 所佔用的 CPU time 比例
  • st: time stolen from this vm by the hypervisor

0x04 參考資料

operating_system/useful_command/nix_vmstat_command.txt · 上一次變更: 127.0.0.1