zabbix4.0添加磁盤io監控


agent服務器端的操作

1.設置zabbix-agent端的配置文件

找到agent端配置文件的位置,本例agent端的配置文件路徑在/usr/local/etc/zabbix下

首先:在主配置文件(zabbix-agentd.conf)中指定agent端監控腳本的存放路徑

 

vim /etc/zabbix_agentd.conf

 

然后:在將監控腳本放到指定位置,監控IO的腳本如下:

#磁盤讀的次數
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}'
#花費在IO操作上的毫秒數
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$13}'
#讀扇區的次數(一個扇區的等於512B)
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}'

 

之后在重啟agent服務:

service zabbix-agent restart

測試zabbix-server獲取數據:

zabbix_get -s 目標服務器IP -p 10050 -k custom.vfs.dev.write.ops[vda]  

 

zabbix-server的web端操作

打開zabbix-server的web頁面,在相應主機上創建監控磁盤IO的監控項

此處一定要設置Preprocessing

 

 

 

所有監控項的配置如下:

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

 類似的配置第二個監控項:

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
Store value: speed per second

第四個監控項:

Name: Disk:$1:Write:ops per second
Key: custom.vfs.dev.write.ops[sda]
Units: ops/second
Store value: speed per second

第五個監控項:

Name: Disk:$1:Read:ms
Key: custom.vfs.dev.read.ms[sda]
Units: ms
Store value: speed per second

第六個監控項:

Name:Disk:$1:Write:ms
Key: custom.vfs.dev.write.ms[sda]
Units: ms
Store value: speed per second

成功添加監控項之后,在添加Graphs,由於添加太過簡單,此處不做過多說明


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM