1、vmstat所需軟件
-
# uname -a
-
Linux test02 2.6.18-92.el5PAE #1
SMP Tue Jun 10 19:22:41 EDT 2008 i686 i686 i386 GNU/Linux
-
# which vmstat
-
/usr/bin/vmstat
-
# rpm -qf /usr/bin/vmstat
- procps-3.2.7-9.el5
2、vmstat語法
-
vmstat [-a] [-n] [delay [ count]]
-
vmstat [-f] [-s] [-m]
-
vmstat [-S unit]
-
vmstat [-d]
-
vmstat [-p disk_partition]
- vmstat [-V]
不加參數的情況下,vmstat的輸出只有一條數據(顯示的結果粘過來上下對應的不是很好)
-
# vmstat
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free buff cache si so bi bo in cs us sy id wa st
- 0 0 0 15173344 159684 1025204 0 0 0 2 1 1 0 0 100 0 0
這個數據是自系統上次重啓之後到現在的平均數值。如果需要額外信息就需要使用參數了。
2.1 參數簡介
[-a]顯示 活動(active)和 非活動(inactive)的內存。
-
# vmstat -a
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free inact active si so bi bo in cs us sy id wa st
- 0 0 0 15173344 257432 1125300 0 0 0 2 1 1 0 0 100 0 0
[ -n ]只顯示頭信息,不週期性顯示。這裏沒有測試出-n的作用,貌似有和沒有,結果都一樣。[ -f ]顯示自開機以來forks的總數,包括fork、vfork和clone system calls,總數和tasks創建的數量是一致的。
-
# vmstat -f
-
662900 forks
-
# vmstat -f
-
662901 forks
-
# vmstat -f
-
662902 forks
-
# vmstat -f
- 662903 forks
[ -s ]顯示各種事件計數器表和內存統計信息,這顯示不重複。
-
# vmstat -s
-
16621896 total memory
-
1450164 used memory
-
1126060 active memory
-
257436 inactive memory
-
15171732 free memory
-
159696 buffer memory
-
1025228 swap cache
-
10241428 total swap
-
0 used swap
-
10241428 free swap
-
407585 non-nice user cpu ticks
-
99282 nice user cpu ticks
-
507104 system cpu ticks
-
4025968737 idle cpu ticks
-
3367298 IO-wait cpu ticks
-
179918 IRQ cpu ticks
-
70168 softirq cpu ticks
-
0 stolen cpu ticks
-
1279463 pages paged in
-
99068439 pages paged out
-
0 pages swapped in
-
0 pages swapped out
-
840368546 interrupts
-
505464033 CPU context switches
-
1296116054 boot time
- 662891 forks
[ -m ]顯示slabinfo,好像是緩存相關的,對這個完全不懂。可以對比一下/proc/slabinfo的內容。內容過多,就不粘貼過來了。
[-V]顯示版本信息。
-
# vmstat -V
- procps version 3.2.7
[ -d ]顯示磁盤數據(disk statistics)
-
# vmstat -d
-
disk- ------------reads------------ ------------writes----------- -----IO------
-
total merged sectors ms total merged sectors ms cur sec
-
ram0 0 0 0 0 0 0 0 0 0 0
-
ram1 0 0 0 0 0 0 0 0 0 0
-
ram2 0 0 0 0 0 0 0 0 0 0
-
ram3 0 0 0 0 0 0 0 0 0 0
-
ram4 0 0 0 0 0 0 0 0 0 0
-
ram5 0 0 0 0 0 0 0 0 0 0
-
ram6 0 0 0 0 0 0 0 0 0 0
-
ram7 0 0 0 0 0 0 0 0 0 0
-
ram8 0 0 0 0 0 0 0 0 0 0
-
ram9 0 0 0 0 0 0 0 0 0 0
-
ram10 0 0 0 0 0 0 0 0 0 0
-
ram11 0 0 0 0 0 0 0 0 0 0
-
ram12 0 0 0 0 0 0 0 0 0 0
-
ram13 0 0 0 0 0 0 0 0 0 0
-
ram14 0 0 0 0 0 0 0 0 0 0
-
ram15 0 0 0 0 0 0 0 0 0 0
-
sda 78933 11718 2558111 196860 7323094 17437763 198087270 103643068 0 40409
-
sr0 0 0 0 0 0 0 0 0 0 0
- md0 0 0 0 0 0 0 0 0 0 0
[ -D ]顯示磁盤統計表(disk table)
-
# vmstat -D
-
19 disks
-
3 partitions
-
78933 total reads
-
11718 merged reads
-
2558111 read sectors
-
196860 milli reading
-
7323091 writes
-
17437754 merged writes
-
198087174 written sectors
-
103643051 milli writing
-
0 inprogress IO
- 40409 milli spent IO
[ -S 單位 ]k:1000K:1024 (默認爲K)m:1000000M:1048576比較:k和K
-
# vmstat -S k
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free buff cache si so bi bo in cs us sy id wa st
-
0 0 0 15536107 163528 1049833 0 0 0 2 1 1 0 0 100 0 0
-
-
-
# vmstat -S K
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free buff cache si so bi bo in cs us sy id wa st
- 0 0 0 15173840 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
[ -p 分區 ]顯示磁盤分區數據(disk partition statistics )
-
# vmstat -p /dev/sda1
-
sda1 reads read sectors writes requested writes
- 957 1918 19 38
-
-
# vmstat -p /dev/sda2
-
sda2 reads read sectors writes requested writes
- 88375 2554274 24766385 198131080
-
-
# vmstat -p /dev/sda3
-
sda3 reads read sectors writes requested writes
- 1268 1439 0 0
[ delay [ count ] ]delay是間隔,count顯示多少次信息。可以和上面的某些參數結合使用。
-
# vmstat 1 3
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free buff cache si so bi bo in cs us sy id wa st
-
0 0 0 15171484 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
-
1 0 0 15171484 159696 1025228 0 0 0 0 1013 77 0 0 100 0 0
- 0 0 0 15171484 159696 1025228 0 0 0 48 1038 194 0 0 100 0 0
-
-
# vmstat 2 4
-
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
-
r b swpd free buff cache si so bi bo in cs us sy id wa st
-
0 0 0 15173344 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
-
0 0 0 15173344 159696 1025228 0 0 0 52 1037 116 0 0 100 0 0
-
0 0 0 15173344 159696 1025228 0 0 0 0 1027 109 0 0 100 0 0
- 0 0 0 15171484 159696 1025228 0 0 0 32 1023 131 0 0 100 0 0
vmstat 1 3 是每1秒顯示一次,共顯示3次vmstat 2 4 是每2秒顯示一次,共顯示4次