DG-備庫日誌的應用遲時檢查

Steven1981發表於2008-03-26

ora9i,LINUXas3 ,DG歸檔日誌管理,看書筆記,測試 ,測試前請先配置SSH金鑰

[@more@]

#first set env
ORACLE_BASE=/SERVER/ora9;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2;export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH;export PATH
ORACLE_SID=ora9i; export ORACLE_SID

#start check
DATE=`date +%Y-%m-%d:%H:%M:%S`
filepath=$ORACLE_BASE/oradata/$ORACLE_SID/archive/
logpath=$ORACLE_BASE/admin/$ORACLE_SID/bdump
remotefile=`ssh -p 10088 oracle@192.168.18.91 "ls -t /SERVER/ora9/oradata/ora9i/archive/*|head -1|sed -e 's/.*_1_//g' |sed -e 's/.log$//g'"`

#!/bin/sh
#first u must set env
ORACLE_BASE=/SERVER/ora9;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2;export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH;export PATH
ORACLE_SID=ora9i; export ORACLE_SID

#start check
DATE=`date +%Y-%m-%d:%H:%M:%S`
filepath=$ORACLE_BASE/oradata/$ORACLE_SID/archive/
logpath=$ORACLE_BASE/admin/$ORACLE_SID/bdump
remotefile=`ssh -p 10088 oracle@192.168.18.91 "ls -t /SERVER/ora9/oradata/ora9i/archive/*|head -1|sed -e 's/.*_1_//g' |sed -e 's/.log$//g'"`

echo "CHECK TIME:"${DATE}
echo "remote file:"$remotefile

cd $filepath
varfile=`ls -tl | grep "ora9i" | head -1|sed -e 's/.*_1_//g' |sed -e 's/.log$//g'`
echo "archive file:"$varfile

cd $logpath
varlog=`grep "Media Recovery Log" alert_${ORACLE_SID}.log | tail -1 |sed -e 's/.*_1_//g' | sed -e 's/.log$//g'`
echo "applice file:"$varlog

vs1=$(($remotefile-$varfile))
vs2=$(($varfile-$varlog))

#if log is not be sended then mail to me
if [ $vs1 -ge 3 ]
then
echo "send error!"
sendmail < $ORACLE_BASE/test.sh
else
echo "send is ok!"
echo
fi

#if log is not be apped then mail to me
if [ $vs2 -ge 3 ]
then
echo "applice error!"
sendmail < $ORACLE_BASE/test.shelse
echo "applice is ok!"
echo
fi

#test.sh內容:
subject:'this is a test letter'
from:oracle@ora9-2.net
to:hyfufo@163.com
test
.
EOF

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/703656/viewspace-1001491/,如需轉載,請註明出處,否則將追究法律責任。

相關文章