Thursday, June 12, 2008

Shell script to analyze Oracle schemas

#!/usr/bin/ksh
#######################################################
#This shell script is used to analyze the Oracle schemas.
# Author:Anbu Subramanian# $1 is the Instance name.
# $2 is the Oracle schema to be analyzed. #########################################################
. /oracle/.102boraenv
INST_DIR=$HOME/analyze
opwd=`cat $INST_DIR/.infodb.$1`
export opwd
mailto:dba_team=
dtstamp=`date +%m%d%Y`
sqlplus -s < $INST_DIR/analyze_$1_$2_$dtstamp.lst 2>&1
$opwd@$1
set echo on
set feedback on
execute dbms_utility.analyze_schema('$2','COMPUTE');END1
/usr/bin/cat $INST_DIR/analyze_$1_$2_$dtstamp.lst grep ORA- > /dev/null 2>&1
if [ $? = 0 ]
then
mailx -s "!!!-IMPORTANT ANALYZING $2@$1 on $dtstamp FAILED." $dba_team< $INST_DIR/analyze_$1_$2_$dtstamp.lst elsemailx -s "ANALYZING $2@$1 SUCCESSFULL on $dtstamp." $dba_team< $INST_DIR/analyze_$1_$2_$dtstamp.lst
fi
rm $INST_DIR/analyze_$1_$2_$dtstamp.lst
exit

No comments: