简单日志监控告警小脚本
2016-05-19 17:09
441 查看
#!/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 doneerrorword.txt文件里可以存放常见错误关键词如:Out of memory,ERROR,Exception等
另外也可以使用for循环脚本周期性取前几分钟时间段的日志进行错误过滤,或者使用日志监控工具如:logstash或zabbix等。
相关文章推荐
- android wifi 无线调试
- 访问Nginx发生SSL connection error的一种情况
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- 使用zabbix监控Nginx活动状态--Part1
- 星外虚拟主机访问被控出现Unspecified error解决方法
- IIS 错误 Server Application Error 详细解决方法
- On Error Resume Next 语句
- shell字符串操作详解
- IIS运行错误 Server Application Error 错误代码 Error: 8004的解决方法
- C#实现简单屏幕监控的方法
- Lua编程示例(一):select、debug、可变参数、table操作、error
- Shell中删除某些文件外所有文件的3个方法
- C#进程监控方法实例分析
- Ruby中执行Linux shell命令的六种方法详解
- 收集整理的http/1.1 500 server error错误的解决方法
- SQL 2005 ERROR:3145 解决办法(备份集中的数据库备份与现有的数据库不同)