Red_Hat Linux
指令名稱: | vmstat |
指令路徑: | /usr/bin/vmstat |
所使用的 shared | library: libproc.so.2.0.7 => /lib/libproc.so.2.0.7 (0x4002f000) libc.so.6 => /lib/libc.so.6 (0x4003c000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) |
主要用途: | vmstat顯示processes, memory ,paging, block IO, traps和cpu activity 第一次執行時出現的information為最後一次boot到目前的平均數值 |
參數: vmstat [-n] [delay [ count]]
vmstat [-V]
範例:
$ | vmstat | |||||||||||
procs | memory | swap | io | system | cpu | |||||||
r | b w | swpd | free | buff | cache | si so | bi | bo | in cs | us | sy | id |
0 | 0 0 | 5168 | 33008 | 41404 | 28440 | 0 0 | 2 | 2 | 39 21 | 0 | 0 | 1 |
先解說每個符號的意義
Process的部分:
r: The number of processes waiting for run time. b: The number of processes in uninterruptable sleep. w: The number of processes swapped out but otherwise runnable. This field is calculated, but Linux never desperation swaps.
Memory的部分:
swpd: 虛擬記憶體(swap)的使用量 (單位:kb) free: 剩餘記憶體的數量 (單位:kb) buff: 被當作buffer使用的記憶體
Swap的部分:(單位:kb) si: 從disk swapped到memory的量 (單位:kb/s) so: 從memory swapped到disk的量
Io的部分:(單位:kb/s) bi: Blocks sent to a block device (單位:blocks/s) bo: Blocks received from a block device (單位:blocks/s) System的部分:
in: 每秒interrupt的次數
cs: 每秒context switches的次數
Cpu的部分:(皆指所佔cpu time的百分比)
us: user time
sy: system time
id: idle time
$ | vmstat 1 | ||||||
procs | memory | swap | io | system cpu | |||
r | b | w | swpd free buff | cache | si so bi | bo | in cs us sy id |
0 | 0 | 0 | 5168 29360 43388 | 28484 | 0 0 2 | 2 | 39 21 0 0 1 |
0 | 0 | 0 | 5168 29360 43388 | 28484 | 0 0 0 | 0 | 109 14 0 2 98 |
0 . . . |
0 | 0 | 5168 29360 43388 | 28484 | 0 0 0 | 0 | 108 18 0 2 98 |
etc.
先看指令,加了一個idle的參數1,代表每一秒鐘更新一次 而且沒有指定count,所以會一值統計到^C結束為止
第一列的數值代表最後一次boot到當時的平均值, 其後幾列的數值都是代表區間(此時為1)的平均值
$ | vmstat | 2 5 | |||||||||||||
procs | memory | swap | io | system | cpu | ||||||||||
r | b | w | swpd | free | buff | cache | si | so | bi | bo | in | cs | us | sy | id |
0 | 0 | 0 | 5168 | 29360 | 43388 | 28484 | 0 | 0 | 2 | 2 | 39 | 21 | 0 | 0 | 1 |
0 | 0 | 0 | 5168 | 29360 | 43388 | 28484 | 0 | 0 | 0 | 0 | 110 | 10 | 0 | 1 | 99 |
0 | 0 | 0 | 5168 | 29360 | 43388 | 28484 | 0 | 0 | 0 | 0 | 112 | 10 | 0 | 1 | 99 |
0 | 0 | 0 | 5168 | 29360 | 43388 | 28484 | 0 | 0 | 0 | 0 | 110 | 10 | 0 | 0 | 99 |
0 | 0 | 0 | 5168 | 29360 | 43388 | 28484 | 0 | 0 | 0 | 2 | 124 | 10 | 0 | 1 | 99 |
此時參數比剛剛又增加了count(5),所以只執行了五次 |
vmstat -n 1 與 vmstat 1 有什麼不同呢?(以下有範例解說)
$vmstat | n 1 | ||||||||||||||
procs | memory | swap | io | system | cpu | ||||||||||
r | b | w | swpd | free | buff | cache | si | so | bi | bo | in | cs | us | sy | id |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 2 | 2 | 39 | 21 | 0 | 0 | 1 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 28 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 121 | 20 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 110 | 18 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 118 | 22 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 114 | 17 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 12 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 5 | 149 | 16 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 110 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 15 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 111 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 116 | 16 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 14 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 13 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 112 | 14 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 114 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 116 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 120 | 15 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 16 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 115 | 28 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 118 | 32 | 0 | 2 | 98 |
$ | vmstat | 1 | |||||||||||||
procs | memory | swap | io | system | cpu | ||||||||||
r | b | w | swpd | free | buff | cache | si | so | bi | bo | in | cs | us | sy | id |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 2 | 2 | 39 | 21 | 0 | 0 | 1 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 28 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 121 | 20 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 110 | 18 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 118 | 22 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 114 | 17 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 113 | 12 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 5 | 149 | 16 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 110 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 15 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 111 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 116 | 16 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 14 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 13 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 108 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 112 | 14 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 114 | 14 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 116 | 12 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 120 | 15 | 1 | 1 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 109 | 16 | 1 | 1 | 98 |
procs | memory | swap | io | system | cpu | ||||||||||
r | b | w | swpd | free | buff | cache | si | so | bi | bo | in | cs | us | sy | id |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 115 | 28 | 0 | 2 | 98 |
0 | 0 | 0 | 5168 | 28984 | 43404 | 28496 | 0 | 0 | 0 | 0 | 118 | 32 | 0 | 2 | 98 |
由此可知,原本當資料過長超過一頁所能容納時,header會再列印一遍 但是加上了-n就不會列出header了
$ vmstat -V
procps version 2.0.7
秀出vmstat的version,此例為 version 2.0.7