vmstat語法及參數介紹

1、vmstat所需軟件

  1. # uname -a
  2. Linux test02 2.6.18-92.el5PAE #1 SMP Tue Jun 10 19:22:41 EDT 2008 i686 i686 i386 GNU/Linux
  3. # which vmstat
  4. /usr/bin/vmstat
  5. # rpm -qf /usr/bin/vmstat
  6. procps-3.2.7-9.el5
2、vmstat語法

  1. vmstat [-a] [-n] [delay [ count]]
  2.        vmstat [-f] [-s] [-m]
  3.        vmstat [-S unit]
  4.        vmstat [-d]
  5.        vmstat [-p disk_partition]
  6.        vmstat [-V]
不加參數的情況下,vmstat的輸出只有一條數據(顯示的結果粘過來上下對應的不是很好)

  1. # vmstat
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  3.  r b swpd free buff cache si so bi bo in cs us sy id wa st
  4.  0 0 0 15173344 159684 1025204 0 0 0 2 1 1 0 0 100 0 0
這個數據是自系統上次重啓之後到現在的平均數值。如果需要額外信息就需要使用參數了。
 
2.1 參數簡介

[-a]
顯示 活動(active)和 非活動(inactive)的內存。

  1. # vmstat -a
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  3.  r b swpd free inact active si so bi bo in cs us sy id wa st
  4.  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創建的數量是一致的。

  1. # vmstat -f
  2.        662900 forks
  3. # vmstat -f
  4.        662901 forks
  5. # vmstat -f
  6.        662902 forks
  7. # vmstat -f
  8.        662903 forks
[ -s ]
顯示各種事件計數器表和內存統計信息,這顯示不重複。

  1. # vmstat -s
  2.      16621896 total memory
  3.       1450164 used memory
  4.       1126060 active memory
  5.        257436 inactive memory
  6.      15171732 free memory
  7.        159696 buffer memory
  8.       1025228 swap cache
  9.      10241428 total swap
  10.             0 used swap
  11.      10241428 free swap
  12.        407585 non-nice user cpu ticks
  13.         99282 nice user cpu ticks
  14.        507104 system cpu ticks
  15.    4025968737 idle cpu ticks
  16.       3367298 IO-wait cpu ticks
  17.        179918 IRQ cpu ticks
  18.         70168 softirq cpu ticks
  19.             0 stolen cpu ticks
  20.       1279463 pages paged in
  21.      99068439 pages paged out
  22.             0 pages swapped in
  23.             0 pages swapped out
  24.     840368546 interrupts
  25.     505464033 CPU context switches
  26.    1296116054 boot time
  27.        662891 forks

[ -m ]
顯示slabinfo,好像是緩存相關的,對這個完全不懂。可以對比一下/proc/slabinfo的內容。
內容過多,就不粘貼過來了。

[-V]
顯示版本信息。

  1. # vmstat -V
  2. procps version 3.2.7

[ -d ]
顯示磁盤數據(disk statistics)

  1. # vmstat -d
  2. disk- ------------reads------------ ------------writes----------- -----IO------
  3.        total merged sectors ms total merged sectors ms cur sec
  4. ram0 0 0 0 0 0 0 0 0 0 0
  5. ram1 0 0 0 0 0 0 0 0 0 0
  6. ram2 0 0 0 0 0 0 0 0 0 0
  7. ram3 0 0 0 0 0 0 0 0 0 0
  8. ram4 0 0 0 0 0 0 0 0 0 0
  9. ram5 0 0 0 0 0 0 0 0 0 0
  10. ram6 0 0 0 0 0 0 0 0 0 0
  11. ram7 0 0 0 0 0 0 0 0 0 0
  12. ram8 0 0 0 0 0 0 0 0 0 0
  13. ram9 0 0 0 0 0 0 0 0 0 0
  14. ram10 0 0 0 0 0 0 0 0 0 0
  15. ram11 0 0 0 0 0 0 0 0 0 0
  16. ram12 0 0 0 0 0 0 0 0 0 0
  17. ram13 0 0 0 0 0 0 0 0 0 0
  18. ram14 0 0 0 0 0 0 0 0 0 0
  19. ram15 0 0 0 0 0 0 0 0 0 0
  20. sda 78933 11718 2558111 196860 7323094 17437763 198087270 103643068 0 40409
  21. sr0 0 0 0 0 0 0 0 0 0 0
  22. md0 0 0 0 0 0 0 0 0 0 0
[ -D ]
顯示磁盤統計表(disk table)

  1. # vmstat -D
  2.            19 disks 
  3.             3 partitions 
  4.         78933 total reads
  5.         11718 merged reads
  6.       2558111 read sectors
  7.        196860 milli reading
  8.       7323091 writes
  9.      17437754 merged writes
  10.     198087174 written sectors
  11.     103643051 milli writing
  12.             0 inprogress IO
  13.         40409 milli spent IO

[ -S 單位 ]
k:1000
K:1024 (默認爲K)
m:1000000
M:1048576
比較:k和K

  1. # vmstat -S k
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  3.  r b swpd free buff cache si so bi bo in cs us sy id wa st
  4.  0 0 0 15536107 163528 1049833 0 0 0 2 1 1 0 0 100 0 0


  5. # vmstat -S K
  6. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  7.  r b swpd free buff cache si so bi bo in cs us sy id wa st
  8.  0 0 0 15173840 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
 
[ -p 分區 ]
顯示磁盤分區數據(disk partition statistics )

  1. # vmstat -/dev/sda1
  2. sda1 reads read sectors writes requested writes
  3.                  957 1918 19 38

  4. # vmstat -/dev/sda2
  5. sda2 reads read sectors writes requested writes
  6.                88375 2554274 24766385 198131080

  7. # vmstat -/dev/sda3
  8. sda3 reads read sectors writes requested writes
  9.                 1268 1439 0 0

[ delay [ count ] ]
delay是間隔,count顯示多少次信息。可以和上面的某些參數結合使用。

  1. # vmstat 1 3
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  3.  r b swpd free buff cache si so bi bo in cs us sy id wa st
  4.  0 0 0 15171484 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
  5.  1 0 0 15171484 159696 1025228 0 0 0 0 1013 77 0 0 100 0 0
  6.  0 0 0 15171484 159696 1025228 0 0 0 48 1038 194 0 0 100 0 0

  7. # vmstat 2 4
  8. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  9.  r b swpd free buff cache si so bi bo in cs us sy id wa st
  10.  0 0 0 15173344 159696 1025228 0 0 0 2 1 1 0 0 100 0 0
  11.  0 0 0 15173344 159696 1025228 0 0 0 52 1037 116 0 0 100 0 0
  12.  0 0 0 15173344 159696 1025228 0 0 0 0 1027 109 0 0 100 0 0
  13.  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次
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章