东西都上传到这里了:
https://github.com/RexKang/Zabbix/tree/master/OS/Linux-disk-discovery
需要用到的东西:
Zabbix的LLD:https://www.zabbix.com/documentation/2.0/manual/discovery/low_level_discovery
Zabbix的Agent配置:https://www.zabbix.com/documentation/2.0/manual/appendix/config/zabbix_agentd
iostat的使用:http://www.cnblogs.com/peida/archive/2012/12/28/2837345.html
1、修改agent配置
我的agent安装位置是/usr/local/zabbixagent/
vi /usr/local/zabbixagent/conf/zabbix_agentd.conf Include=/usr/local/zabbixagent/conf/zabbix_agentd :wq
2、建立配置文件
此文件位置在/usr/local/zabbixagent/conf/zabbix_agentd/sysio.conf
# required sysstat # required iostat running backgroud ################################################## # nohup iostat -k -x -d 30 > /usr/local/zabbixagent/tmp/iostats & # chown zabbix:zabbix /usr/local/zabbixagent/tmp/iostats # cronteb -e # Zabbix Agent‘s task for disk I/O # 59 23 * * * iostat -k -x -d 30 2 > /usr/local/zabbixagent/tmp/iostats & ################################################## # command for test. #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.rps[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.wps[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.rkbps[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.wkbps[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.avgrq-sz[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.avgqu-sz[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.await[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.svctm[sda]‘ #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.util[sda]‘ ################################################## UserParameter=io.scandisk[*],/usr/local/zabbixagent/scripts/discovery-linux.py /proc/diskstats 3 UserParameter=io.rps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$4}‘ UserParameter=io.wps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$5}‘ UserParameter=io.rkbps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$6}‘ UserParameter=io.wkbps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$7}‘ UserParameter=io.avgrq-sz[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$8}‘ UserParameter=io.avgqu-sz[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$9}‘ UserParameter=io.await[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$10}‘ UserParameter=io.svctm[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$11}‘ UserParameter=io.util[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk ‘{print $$12}‘
3、misc
cd /usr/local/zabbixagent/ mkdir tmp scripts chmod 775 tmp scripts touch tmp/iostats chmod 644 tmp/iostats touch scripts/discovery-linux.py chmod 754 scripts/discovery-linux.py chown zabbix:zabbix ./* -R
4、运行
nohup iostat -k -x -d 30 > /usr/local/zabbixagent/tmp/iostats & sudo service zabbix_agentd restart
5、测试
/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.rps[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.wps[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.rkbps[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.wkbps[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.avgrq-sz[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.avgqu-sz[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.await[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.svctm[sda]‘ /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k ‘io.util[sda]‘
6、添加清理脚本
crontab -e 59 8 * * * iostat -k -x -d 30 2 > /usr/local/zabbixagent/tmp/iostats &
7、添加配置
blablabla,这里我就不说了。
Zabbix监控Linux磁盘I/O
时间: 2024-10-13 09:58:13