linux常用系統監控工具之vmstat

yuntui發表於2016-11-03

vmstat是Virtual Meomory Statistics(虛擬記憶體統計)的縮寫,可對os的processes、記憶體、分頁、塊的I/O、traps、CPU活動進行監控。詳細資訊請品讀vmstat的幫助文件。

vmstat語法結構:

image

為了統計的準確,多采集幾組資料:

[root@Jacson ~]# vmstat 3 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
1  0      0 485920  41340 419984    0    0    65     8  437   40  1 19 80  1  0
0  0      0 485920  41356 419988    0    0     0     9  835   56  0 18 82  0  0
0  0      0 485920  41380 419980    0    0     0    17  780   47  0 18 82  0  0
0  0      0 485920  41380 419988    0    0     0     0  792   43  0 22 78  0  0
0  0      0 485920  41396 419988    0    0     0    17  831   46  0 18 82  0  0

對上面的輸出做一下解釋:

proces:

r: The number of processes waiting for run time.這個值長期大於系統CPU的個數,說明CPU不足,需要增加CPU

b: The number of processes in uninterruptible sleep.等待的內容可能為I/O說著記憶體交換

Memory
       swpd: the amount of virtual memory used.(以KB為單位)

       free: the amount of idle memory.(以KB為單位)
       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).

在一般情況下si/so的值都為0,如果長期不為0,那麼在oracle應用下最好先檢視記憶體分配/引數,其他應用估計要增加記憶體

IO
       bi: Blocks received from a block device (blocks/s).(單位是KB/S)
       bo: Blocks sent to a block device (blocks/s).(單位是KB/S)

在知道系統I/O頻寬的情況下,bi+bo如果大於I/O頻寬且wa(wait)值比較大,則表示系統I/O真的有問題,估計是要採取措施了

System
       in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.

上面2個值越大,表示由核心消耗的CPU時間越多。

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, included in idle.
       st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

1.給據實際經驗:us+sy的最大參考值為85%,如果us+sy大於85%,說明目前系統CPU資源很緊張。

wa的參考值為30%,(根據硬體RAID的讀寫分配比例)如果大於最小的分配值,說明等待嚴重。一般情況下引起I/O較高的操作都是大量的隨機讀寫引起的,比如(select * from table)

綜上所述,再對CPU做資源評估時結合proces的r列的值和CPU項中的us+sy和id列的值,做綜合評比!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27144762/viewspace-1132474/,如需轉載,請註明出處,否則將追究法律責任。

相關文章