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 hyfufo@163.com < $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 hyfufo@163.com < $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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/703656/viewspace-1001491/