需求:监控服务器硬盘使用率是否有超过80%的
需要监控的文本
root@zabbix zabbix]# cat /etc/zabbix/scripts/data/monitor_disk.txt
"results": {"ac00cc2d.qq.com":{"monitor_disk_root":"3.6G"}
"cd00eb33.qq.com":{"monitor_disk":"37%"}
"b7225295.qq.com":{"monitor_disk":"37%"}
"13225217.qq.com":{"monitor_disk":"37%"}
"ff00f36f.qq.com":{"monitor_disk":"38%"}
"5600f343.qq.com":{"monitor_disk":"38%"}
"cf00eb8f.qq.com":{"monitor_disk":"38%"}
"13225299.qq.com":{"monitor_disk":"38%"}
"3400eb2f.qq.com":{"monitor_disk":"38%"}
"7700f395.qq.com":{"monitor_disk":"38%"}
"9900f359.qq.com":{"monitor_disk":"38%"}
"2b00f349.qq.com":{"monitor_disk":"38%"}
"2c00f3c1.qq.com":{"monitor_disk":"38%"}
"2500ebc1.qq.com":{"monitor_disk":"38%"}
"432252dd.qq.com":{"monitor_disk":"38%"}
"7e00f31f.qq.com":{"monitor_disk":"38%"}
"7900f397.qq.com":{"monitor_disk":"38%"}
"9f00f38f.qq.com":{"monitor_disk":"38%"}
"fa00f35b.qq.com":{"monitor_disk":"38%"}
"3500eb71.qq.com":{"monitor_disk":"38%"}
"c800eb07.qq.com":{"monitor_disk":"38%"}
"5000f395.qq.com":{"monitor_disk":"38%"}
"f700f3bb.qq.com":{"monitor_disk":"38%"}
"4d00f3cf.qq.com":{"monitor_disk":"38%"}
"7600f323.qq.com":{"monitor_disk":"38%"}
"0300f34d.qq.com":{"monitor_disk":"39%"}
"6300f345.qq.com":{"monitor_disk":"39%"}
"6c00f319.qq.com":{"monitor_disk":"39%"}
"bb00ebf5.qq.com":{"monitor_disk":"39%"}
"9600f305.qq.com":{"monitor_disk":"39%"}
"ba00ebab.qq.com":{"monitor_disk":"39%"}
"7c00f3a3.qq.com":{"monitor_disk":"39%"}
"3600eb93.qq.com":{"monitor_disk":"39%"}
"c400ebb9.qq.com":{"monitor_disk":"39%"}
"0700f327.qq.com":{"monitor_disk":"39%"}
"7600f3cb.qq.com":{"monitor_disk":"39%"}
"6b00f391.qq.com":{"monitor_disk":"40%"}
"bf00eb9f.qq.com":{"monitor_disk":"40%"}
"4e00f32d.qq.com":{"monitor_disk":"40%"}
"7500f38b.qq.com":{"monitor_disk":"40%"}
"0000f3af.qq.com":{"monitor_disk":"40%"}
"7100f343.qq.com":{"monitor_disk":"42%"}
"8700e747.qq.com":{"monitor_disk":"42%"}
"f800f3e7.qq.com":{"monitor_disk":"43%"}
"3000e7db.qq.com":{"monitor_disk":"47%"}
"35225275.qq.com":{"monitor_disk":"47%"}
"1322524f.qq.com":{"monitor_disk":"52%"}
"27225237.qq.com":{"monitor_disk":"52%"}
"ed00e7c7.qq.com":{"monitor_disk":"53%"}
"e700e7a5.qq.com":{"monitor_disk":"53%"}}
}
自定义监控脚本
#!/bin/bash
curl -k -u zabbix:passwd https://teletraan.qq.com/api/fact_values?search=monitor_disk > /etc/zabbix/scripts/data/monitor_disk.txt 2>/dev/null
sed -i 's/,/\n/g' /etc/zabbix/scripts/data/monitor_disk.txt
sed -i '1,17d' /etc/zabbix/scripts/data/monitor_disk.txt
result=`cat /tmp/monitor_disk.txt | grep [8-9][0-9]% | grep -v grep`
echo $result > /etc/zabbix/scripts/data/box_disk_80.txt
sed -i 's/ /\n/g' /etc/zabbix/scripts/data/box_disk_80.txt
if [ -n "$result" ]
then
echo '1'
else
echo '0'
fi
zabbix-agent 配置文件中加入监控KEY
vim /etc/zabbix/zabbix_agentd.d/box_disk.conf
UserParameter=box.disk.size[*],/etc/zabbix/scripts/box_disk.sh
添加监控项
配置触发器
配置邮件报警
邮件脚本请参考
http://www.cnblogs.com/37yan/p/7095696.html