实时查看内存使用情况
vmstat 2(秒数)
vmstat 5 40
vmstat 可用來紀錄 processes, memory, paging, block IO, traps, 與 cpu activity。
例如
$ vmstat 1 # 1 是更新速度,單位為秒
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 549368 13316 102388 91992 12 6 9 8 2 12 72 3 25 0
2 0 549368 13316 102388 91992 0 0 0 0 156 1516 98 2 0 0
2 0 549368 13312 102388 91992 0 0 0 0 125 534 99 1 0 0
....
第一列與第二列所代表是執行程式的資訊,接下來的是記憶體、swap、io、systm 與 cpu。
Procs
r: The number of processes 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.
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).
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
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, shown as zero.