天天看點

Zabbix上IO監控

基本原理:通過分析/proc/diskstats檔案,來對IO的性能進行監控。解釋如下:

+++++++++++++++++++++++++++對/proc/diskstats的解釋++++++++++++++++++++++++++++++++++++++++++++

8 0 sda 73840 10263 3178156 91219 1110085 4192562 42423152 1275861 0 447798 1366379

第一至第三個域,分别是主裝置号,次裝置号,裝置名稱

第4個域:讀完成次數 ----- 讀磁盤的次數,成功完成讀的總次數。

(number of issued reads. This is the total number of reads completed successfully.)

第5個域:合并讀完成次數, 第9個域:合并寫完成次數。為了效率可能會合并相鄰的讀和寫。進而兩次4K的讀在它最終被處理到磁盤上之前可能會變成一次8K的讀,才被計數(和排隊),是以隻有一次I/O操作。這個域使你知道這樣的操作有多頻繁。

(number of reads merged)

第6個域:讀扇區的次數,成功讀過的扇區總次數。

(number of sectors read. This is the total number of sectors read successfully.)

第7個域:讀花費的毫秒數,這是所有讀操作所花費的毫秒數(用__make_request()到end_that_request_last()測量)。

(number of milliseconds spent reading. This is the total number of milliseconds spent by all reads (as measured from __make_request() to end_that_request_last()).)

第8個域:寫完成次數 ----寫完成的次數,成功寫完成的總次數。

(number of writes completed. This is the total number of writes completed successfully.)

第9個域:合并寫完成次數 -----合并寫次數。

(number of writes merged Reads and writes which are adjacent to each other may be merged for efficiency. Thus two 4K reads may become one 8K read before it is ultimately handed to the disk, and so it will be counted (and queued) as only one I/O. This field lets you know how often this was done.)

第10個域:寫扇區次數 ---- 寫扇區的次數,成功寫扇區總次數。

(number of sectors written. This is the total number of sectors written successfully.)

第11個域:寫操作花費的毫秒數  ---  寫花費的毫秒數,這是所有寫操作所花費的毫秒數(用__make_request()到end_that_request_last()測量)。

(number of milliseconds spent writing This is the total number of milliseconds spent by all writes (as measured from __make_request() to end_that_request_last()).)

第12個域:正在處理的輸入/輸出請求數 -- -I/O的目前進度,隻有這個域應該是0。當請求被交給适當的request_queue_t時增加和請求完成時減小。

(number of I/Os currently in progress. The only field that should go to zero. Incremented as requests are given to appropriate request_queue_t and decremented as they finish.)

第13個域:輸入/輸出操作花費的毫秒數  ----花在I/O操作上的毫秒數,這個域會增長隻要field 9不為0。

(number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.)

第14個域:輸入/輸出操作花費的權重毫秒數 -----  權重, 花在I/O操作上的毫秒數,在每次I/O開始,I/O結束,I/O合并時這個域都會增加。這可以給I/O完成時間和存儲那些可以累積的提供一個便利的測量标準。

(number of milliseconds spent doing I/Os. This field is incremented at each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/Os in progress (field 9) times the number of milliseconds spent doing I/O since the last update of this field. This can provide an easy measure of both I/O completion time and the backlog that may be accumulating.)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

接下來就是在zabbix agent的配置檔案做操作:

vi /usr/local/zabbix/etc/zabbix_agentd.conf

UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$4}'                    //磁盤讀的次數

UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$7}'                     //磁盤讀的毫秒數

UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$8}'                   //磁盤寫的次數

UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$11}'                  //磁盤寫的毫秒數

UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$12}'            

UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$13}'                       //花費在IO操作上的毫秒數

UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$6}'             //讀扇區的次數(一個扇區的等于512B)

UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$10}'          //寫扇區的次數(一個扇區的等于512B)

測試指令如下:

111153

添加名額:思路:首先添加模闆 ,然後在模闆上添加item。

名額細節:

第一個名額Name:      Disk:$1:Read:Bytes/sec

                  Key:          custom.vfs.dev.read.sectors[sda]

                  Units:        B/sec

                  Store value: speed per second    //會進行內插補點計算

                  Use custom multiplier     512      //會對值乘以512,因為這裡是一個扇區,轉換為位元組為512B

Zabbix上IO監控

同理,其他名額方式,添加如下:

第二個名額:Name:      Disk:$1:Write:Bytes/sec

                  Key:          custom.vfs.dev.write.sectors[sda]

                  Units:        B/sec

                  Store value: speed per second

                  Use custom multiplier     512

第三個名額:Name:      Disk:$1:Read:ops per second

                  Key:          custom.vfs.dev.read.ops[sda]

                  Units:        ops/second

第四個名額:Name:      Disk:$1:Write:ops per second

                  Key:          custom.vfs.dev.write.ops[sda]

第五個名額:Name:     Disk:$1:Read:ms

                  Key:         custom.vfs.dev.read.ms[sda]

                  Units:      ms

第六個名額:Name:     Disk:$1:Write:ms

                  Key:         custom.vfs.dev.write.ms[sda]

     本文轉自yzy121403725 51CTO部落格,原文連結:http://blog.51cto.com/lookingdream/1855045,如需轉載請自行聯系原作者