alert_error_daily
#!/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
#遮蔽了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部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2131727/,如需轉載,請註明出處,否則將追究法律責任。