#!/usr/bin/ksh
#############
# VARIABLES #
#############
this_process=$$
this_script=`basename $0 | cut -f1 -d.`
this_report="${this_script}.report"
cat /dev/null > ${this_report}
#count_args=$#
#############
# VARIABLES #
#############
this_process=$$
this_script=`basename $0 | cut -f1 -d.`
this_report="${this_script}.report"
cat /dev/null > ${this_report}
##################
# FUNCTION / SUB #
##################
##################
# SUB : on_start #
##################
on_start()
{
echo ""
echo "Press CTRL-C to ABORT or <ENTER> to CONTINUE ... \c"
read dummy
echo ""
echo ""
echo "+---------------------------------------------------------------------+"
echo ""
echo "Start running <- ${this_script} ->"
echo "DATE : `date`"
echo ""
echo ""
}
#################
# SUB : on_exit #
#################
on_exit()
{
echo ""
echo "+---------------------------------------------------------------------+"
echo "Search and remove tmp files on `pwd` ..."
echo " `pwd`"
echo "+---------------------------------------------------------------------+"
echo ""
for tmpfile in `ls -1 ${this_script}.tmp.*`
do
echo "rm $tmpfile"
rm $tmpfile
done
echo ""
echo "Check the report file -> ${this_report}"
echo ""
exit 0
}
########################
# SUB : check_argument #
########################
check_argument()
{
echo "+----------------------------------------------+"
echo " Database running on `hostname` :"
echo " DATE : `date`"
echo "+----------------------------------------------+"
echo ""
echo "Or you set on the current database to check [Y/N] ??? \c"
read v_database_set
echo ""
v_database_set=`echo ${v_database_set} | tr [:lower:] [:upper:]`
case ${v_database_set} in
Y|YES) v_db=$ORACLE_SID
echo ""
ps -ef | grep _pmon | grep -v grep
echo ""
;;
N|NO) echo ""
ps -ef | grep _pmon | grep -v grep
echo ""
echo ""
echo "Enter the database SID to check : \c"
read v_db
echo ""
ps -e -o args | grep ora_pmon | grep -v grep > ${this_script}.tmp.00
cat /dev/null > ${this_script}.tmp.01
while read line
do
db=`echo $line | cut -c10-${$}`
echo ${db} >> ${this_script}.tmp.01
done < ${this_script}.tmp.00
if [ -z "`grep -i "^${v_db}$" ${this_script}.tmp.01`" ] ; then
echo ""
echo "You provided an invalid SID ... exiting ..."
echo ""
on_exit
exit 9
else
v_db=`grep -i "^${v_db}$" ${this_script}.tmp.01`
fi
;;
*) echo "Invalid answer !!! Exiting ..."
echo ""
on_exit
;;
esac
echo "DEBUG : v_db -> ${v_db}"
}
#######################
# SUB : report_01 #
#######################
report_01()
{
echo
echo "Running report_01 ..."
echo
sleep 5
}
#######################
# SUB : report_02 #
#######################
report_02()
{
echo
echo "Running report_02 ..."
echo
sleep 5
}
########
# MAIN #
########
on_start | tee -a ${this_report}
check_argument | tee -a ${this_report}
report_01 | tee -a ${this_report}
report_02 | tee -a ${this_report}
on_exit | tee -a ${this_report}
###########
# THE END #
###########