mo_alert log监控

#!/bin/bash
source /home/oracle/.bash_profile
#mail_list='zhxx@xx.net,[url=mailto:zhangxx@xx.net]zhangxx@xx.net,139xxxxxxxx@139.com,135xxxxxxxx@139.com'[/url]

alert_log=/u01/app/oracle/diag/rdbms/orcl_p/orcl/trace/alert_orcl.log
if [ ! -e /tmp/mo_alert.log ]
then
echo "make mailinfo"
touch /tmp/mo_alert.log
current_line=`wc -l $alert_log|awk '{print $1}'`
echo $current_line>/tmp/current.log
else
last_line=`cat /tmp/current.log`
echo "last line: "$last_line
current_line=`wc -l $alert_log|awk '{print $1}'`
echo "current_line: "$current_line
rm -rf /tmp/mo_alert.log
sed -n "$last_line,$current_line p" $alert_log|grep -nB4 -nA4 'ORA-' > /tmp/mo_alert.log
n=`wc -l /tmp/mo_alert.log | awk '{print $1}'`
current_line=`expr $current_line + 1`

if [ $n -gt 0 ]
then
echo "find ORA error send mail"
##cat . /tmp/mo_alert.log |mutt -s "alert on 4.22" $mail_list
echo $current_line >/tmp/current.log
else
echo "no error"
echo $current_line >/tmp/current.log
fi
fi

最新版:

#!/usr/bin/bash

##定义alert日志路径
Alter_log_dir=/data/app/oracle/database/diag/rdbms/siebproda/siebprod/trace/alert_siebprod.log


if [ ! -f "/home/oracle/scripts/log_allrow.txt" ];then
    touch /home/oracle/scripts/log_allrow.txt
    echo  "1" > /home/oracle/scripts/log_allrow.txt
fi

##定义上次日志行起点
Begin_row=`sed -n '1p' /home/oracle/scripts/log_allrow.txt`
##定义日志行截止点
End_row=`wc -l $Alter_log_dir |awk '{print $1}'`
##获取主机IP
Host=`hostname`
sed -n ''$Begin_row','$End_row'p' $Alter_log_dir >/tmp/new_alert_SIEBUAT.log
Excep_row=`egrep -i "ora-|warning" /tmp/new_alert_SIEBUAT.log |wc -l`

if [ $Excep_row -ne 0 ]; then
        egrep -iC 5 "ora-|warning" /tmp/new_alert_SIEBUAT.log >/tmp/error.log
        echo -e "$Host siebel Prod环境数据库alert日志有异常\n`cat /tmp/error.log` " |mail -s "siebel数据库Prod环境报警" DBA@immotors.com >/dev/null 2>&1
else
        echo "`date +%F-%T` ------ NO Error in alert.log" >>/tmp/alert_normal.log
fi


##下一次日志截取点
echo $(($End_row +1)) >/home/oracle/scripts/log_allrow.txt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东方-phantom

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值