04、Apache 监控

1、目的:

     编写一个脚本,4分钟执行一次,检查8分钟内有400错误就发送邮件到noc组
2、技术要点:

    1)date处理,x分钟前通过函数获得;

curdate=`date '+%Y-%m-%d' -d '8 minutes ago' `

    2)grep多条件;

|grep  'WebApi.webapi HTTP/1.1" 400' |grep -c "${minutesago1}\|${minutesago2}\|${minutesago3}\|${minutesago4}\|${minutesago5}\|${minutesago6}\|${minutesago7}\|${minutesago8}"`

    3)获取当前文件若干行作为输入数据;

tail -n 2000   /infowarelab/apache2/logs/access-$curdate.log

猜你喜欢

转载自restart1107.iteye.com/blog/969792