#!/bin/bash
#屏蔽了inbound connection timed out这行和与之相关的上2行和下3行的信息
source /home/oradbm/.bash_profile
mail_list='XX@YY.com,XX@YY.com'
alert_log=/u01/app/db/diag/rdbms/plmdb/PLMDB/trace/alert_PLMDB.log
if [ ! -e /tmp/mailinfo ]
then
touch /tmp/mailinfo
current_line=`wc -l $alert_log|awk '{print $1}'`
echo $current_line>/tmp/mailinfo
else
last_line=`cat /tmp/mailinfo`
echo "上次行数:"$last_line
current_line=`wc -l $alert_log|awk '{print $1}'`
echo "本次行数:"$current_line
sed -n "$last_line,$current_line p" $alert_log|grep -v 'inbound connection timed out'|grep -B2 -A3 'ORA-'>/tmp/mailinfo
n=`wc -l /tmp/mailinfo | awk '{print $1}'`
if [ $n -gt 0 ]
then
echo "检测到错误,发邮件"
cat /tmp/mailinfo|mailx -s "PB 192.168.10.20 alert中出现ORA错误,请检查" $mail_list
echo $current_line>/tmp/mailinfo
else
echo "没检测到错误,不发邮件"
echo $current_line>/tmp/mailinfo
fi
fi
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30126024/viewspace-2131727/
,如需转载,请注明出处,否则将追究法律责任。