01.在服务端创建zabbix组
e>
02.创建—-发现规则
administration--General---Regular expressions ---New Regular expressions
Name: Disk device for discovery
Test string: xvdb
Expression: ^(sda|sdb|xvda|xvdb)$
Expression type: Result is TRUE
Case sensitive: Yes
配置完成记得选择test---然后保存:
iops 创建规则
![zabbix](/img/regular.png)
03.服务端配置。
下载模板,导入模板:
wget https://raw.githubusercontent.com/dkanbier/zabbix-linux/master/templates/zbx_linux_disk_io_template.xml --no-check-certificate
导入模板 ============= 然后应用
客户端如下操作:
01.创建目录
1015 mkdir -p /opt/zabbix/linux
1016 cd /opt/zabbix/linux/
1018 wget https://raw2.github.com/dkanbier/zabbix-linux/master/LLD/queryDisks.pl --no-check-certificate
1019 chmod +x queryDisks.pl
1020 chown -R zabbix:zabbix /opt/zabbix/ -R
02.修改配置文件添加如下内容:
/usr/local/etc/zabbix_agentd.conf
UserParameter=custom.vfs.dev.discovery,/opt/zabbix/linux/queryDisks.pl
03.zabbix配置应用:
配置客户端的key,下载客户端KEY文件
wget https://raw2.github.com/dkanbier/zabbix-linux/master/UserParameters/ userparameter_linux_disks.conf --no-check-certificate
查看:
[root@dota-db-08 zabbix_agentd.conf.d]# cat userparameter_linux_disks.conf
#See https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
#
# reads completed successfully
UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$4}'
# sectors read
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$6}'
# time spent reading (ms)
UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$7}'
# writes completed
UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$8}'
# sectors written
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$10}'
# time spent writing (ms)
UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$11}'
# I/Os currently in progress
UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$12}'
# time spent doing I/Os (ms)
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$13}'
04.重启:
[root@dota-db-08 zabbix_agentd.conf.d]# /etc/rc.d/init.d/zabbix_agentd restart
Shutting down zabbix_agentd: [ OK ]
Starting zabbix_agentd: [ OK ]
[root@dota-db-08 zabbix_agentd.conf.d]#
如下是客户端可以用脚本来执行:
mkdir -p /opt/zabbix/linux && cd /opt/zabbix/linux/ && mkdir /usr/local/etc/zabbix_agentd.conf.d -p && wget https://raw2.github.com/dkanbier/zabbix-linux/master/LLD/queryDisks.pl --no-check-certificate && chmod +x queryDisks.pl && chown -R zabbix:zabbix /opt/zabbix/ -R && echo "UserParameter=custom.vfs.dev.discovery,/opt/zabbix/linux/queryDisks.pl" >> /usr/local/etc/zabbix_agentd.conf && cd /usr/local/etc/zabbix_agentd.conf.d && wget https://raw2.github.com/dkanbier/zabbix-linux/master/UserParameters/userparameter_linux_disks.conf --no-check-certificate && killall -9 zabbix_agentd && rm -rf /etc/init.d/zabbix_agentd && chown root:root /usr/local/zabbix/ -R && chmod +x /etc/init.d/zabbix_agentd && chmod +x /usr/bin/who && chown root:root /usr/local/zabbix/ -R && sed -i 's/# Include=\/usr\/local\/etc\/zabbix_agentd.conf.d/ Include=\/usr\/local\/etc\/zabbix_agentd.conf.d/' /usr/local/etc/zabbix_agentd.conf && /etc/rc.d/init.d/zabbix_agentd start
然后可以查看效果图:
![zabbix](/img/iops.png)
参考如下文章:
http://www.denniskanbier.nl/blog/monitoring/monitoring-disk-io-using-zabbix/
http://www.muck.net/19/getting-hard-disk-performance-stats-from-zabbix