In the morning yo want to check the alert.log file, but only for the changes. There is some work required to determine when udid you last time look at the file, where to start reading etc. Also on Monday you want to report since Friday etc.
The following commands will extract only the changes since the last time you have run the report:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
if [[ -f $log.last ]] then
#get the last reported line
today=`cat $log.last`
else
#find the last date in the file
lastdt=`tail $log|grep :|grep 200|tail -1|cut -c-11`
#get the first occurrence of that date
today=`grep -n "$lastdt" $log|head -1|tr ':' '\012'|head -1`
fi
#remember the last line:
echo `wc -l $log`>$log.last
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
# the rest is up to you.
Alternatively, you could run a cron job to get the number of lines:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
echo `wc -l $log`>$log.last
#In the morning you just report data from the file:
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
Look for anything of interest in the $newlog file
The following commands will extract only the changes since the last time you have run the report:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
if [[ -f $log.last ]] then
#get the last reported line
today=`cat $log.last`
else
#find the last date in the file
lastdt=`tail $log|grep :|grep 200|tail -1|cut -c-11`
#get the first occurrence of that date
today=`grep -n "$lastdt" $log|head -1|tr ':' '\012'|head -1`
fi
#remember the last line:
echo `wc -l $log`>$log.last
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
# the rest is up to you.
Alternatively, you could run a cron job to get the number of lines:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
echo `wc -l $log`>$log.last
#In the morning you just report data from the file:
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
Look for anything of interest in the $newlog file
0 comments:
Post a Comment