自定义key值,匹配1分钟前nginx error log出现的次数。
nginx_error_log的日志格式:
2016/12/05 21:01:29 [error] 13672#0: *440841 open() "/data/didipingang/steel-front/js/libs/angular-file-upload.js.map" failed (2: No such file or directory), client: 10.10.1.27, server: _, request: "GET /js/libs/angular-file-upload.js.map HTTP/1.0", host: "ddpg-static-steel-front"
脚本如下:
#!/bin/bash function error { date=`date -d "1 minutes ago" | awk ‘{print $4}‘ | cut -d: -f1,2` grep $date /usr/local/nginx/log/error.log | egrep -i "failed|no|not|denied|error" | wc -l } $1
执行结果如下:
$ sh error_log.sh error 7
在zabbix_agentd.conf文件添加此行
cat zabbix_agentd.conf UserParameter=erro_log[*],/usr/local/zabbix/share/zabbix/alertscripts/error_log.sh $1
重启zabbix agent
/etc/init.d/zabbix_agentd restart
添加web监控模板:
添加应用集:
添加自定义key:
添加绘图:
模板请到入监下载:
本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1879738
原文地址:http://215687833.blog.51cto.com/6724358/1879738