下面介绍的是用zabbix监控Liunx服务器的IO读写情况. zabbix的安装以前的博客有, 大家可以参考;
1、 添加userparameter_io.conf配置文件
在/etc/zabbix/zabbix_agentd.d下添加userparameter_io.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}'
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$6}'
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$10}'
2.、重启zabbix-agent服务
# service zabbix-agent restart
3、测试zabbix-server获取数据
#zabbix_get -s 目标服务器IP -p 10050 -k custom.vfs.dev.write.ops[sda]
4、配置zabbix-server模板
5.、配置zabbix-server项目(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
同理,其他指标方式,添加如下:
第二个指标: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
6.、添加zabbix-server图形(Graphs)
7、效果图展示
来源:51CTO
作者:今歌
链接:https://blog.51cto.com/huangmanyao/2107337