#!/bin/bash #monitor tomcat_log LOG_DIR=/root/catalina.out IP=`ifconfig | grep "inet addr" | grep Bcast | awk -F ‘[ :]+‘ ‘{print $4}‘` tail -Fn0 $LOG_DIR| while read line;do echo $line | grep -i -f /root/errorword.txt >/dev/null if [ $? -eq 0 ];then echo -e "IP: $IP \n Datetime: $(date) \n Problem: $line" | mail -s "Warning:$IP Log Error " 510264942@qq.com echo "$IP,$(date),$line" >>/var/log/error_report.log fi done
errorword.txt文件里可以存放常见错误关键词如:Out of memory,Error等
日志监控工具可参考logstash或zabbix
本文出自 “Just be myself” 博客,请务必保留此出处http://liubin0505star.blog.51cto.com/5550456/1775110
原文地址:http://liubin0505star.blog.51cto.com/5550456/1775110