vmstat是Virtual Meomory Statistics(虛擬內存統計)的縮寫,可對操作系統的虛擬內存、進程、CPU活動進行監控。
語法
vmstat [ -a ] [ -f ] [ -s ] [ -p ] [ -d ] [ PhysicalVolume … ] [ Interval [ Count ] ]
- -a: 顯示活躍和非活躍內存,所顯示的內容除增加inact和active
- -f: 顯示顯示從系統啓動至今的fork數量,Linux 新建進程用fork
- -s: 查看內存使用的詳細信息
- -d: 查看磁盤的讀/寫
- -p: 顯示指定磁盤分區統計信息
- PhysicalVolume 參數指定物理卷的名稱。
vmstat
[root@iZwz9hmb50uzud432t180uZ ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
3 0 0 148624 0 191716 0 0 2 4 19 4 1 2 97 0 0
procs 代表進程
r: 運行隊列中進程數量
b: 等待IO的進程數量
memory 代表內存
swpd: 使用虛擬內存大小
free: 可用內存大小
buff: 用作緩衝的內存大小
cache: 用作緩存的內存大小
swap
si: 每秒從交換區寫到內存的大小
so: 每秒寫入交換區的內存大小
IO
bi: 每秒讀取的塊數
bo: 每秒寫入的塊數
system 系統
in: 每秒中斷數,包括時鐘中斷。【interrupt】
cs: 每秒上下文切換數。 【count/second】
CPU(以百分比表示):
us: 用戶進程執行時間(user time)
sy: 系統進程執行時間(system time)
id: 空閒時間(包括IO等待時間),中央處理器的空閒時間 。以百分比表示。
wa: 等待IO時間
vmstat [ Interval [ Count ] ]
Interval:間隔的秒數
Count:輸出次數
vmstat 2 5 代表每2秒數輸出一次,總共5次
[root@iZwz9hmb50uzud432t180uZ ~]# vmstat 2 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 144452 0 191816 0 0 2 4 19 5 1 2 97 0 0
1 0 0 144424 0 191816 0 0 0 0 1323 2746 1 2 97 0 0
0 0 0 144424 0 191816 0 0 0 0 1311 2708 1 2 97 0 0
0 0 0 144424 0 191816 0 0 0 0 1300 2684 1 2 97 0 0
0 0 0 144424 0 191816 0 0 0 0 1296 2675 2 1 97 0 0
[root@iZwz9hmb50uzud432t180uZ ~]#
vmstat -f
[root@iZwz9hmb50uzud432t180uZ ~]# vmstat -f
135775 forks
vmstat -s
[root@iZwz9hmb50uzud432t180uZ ~]# vmstat -s
1873184 K total memory
1537332 K used memory
1544068 K active memory
69608 K inactive memory
143876 K free memory
0 K buffer memory
191976 K swap cache
0 K total swap
0 K used swap
0 K free swap
1851311 non-nice user cpu ticks
33174 nice user cpu ticks
2195418 system cpu ticks
209939919 idle cpu ticks
25896 IO-wait cpu ticks
1327938 IRQ cpu ticks
88280 softirq cpu ticks
0 stolen cpu ticks
4958141 pages paged in
9526610 pages paged out
0 pages swapped in
0 pages swapped out
2704827476 interrupts
1299359819 CPU context switches
1578973412 boot time
135776 forks