Monday, June 13, 2016

Shell script to Automate Alert log errors on daily basis (Mailing ORA- errors to DBA )

#!/bin/ksh
ORACLE_HOME=/p01/prod/db/tech_st/11.2.0.4
export ORACLE_HOME
ORACLE_SID=PROD
export ORACLE_SID
echo $ORACLE_HOME
echo $ORACLE_SID
x=$(date +%Y_%m_%d_%H%M%S)
/p01/prod/db/tech_st/11.2.0.4/bin/sqlplus -s / <<EOF
sho parameter db_name
exit;
EOF
if [[ $? -eq 0 ]]; then
#mailx -s "PROD instance is  up !!! "  xyz@gmail.com</tmp
echo "PROD instance is  up !!! "
else
mailx -s "PROD instance is not up !! " xyz@gmail.com</tmp
fi

cd /p01/prod/db/tech_st/11.2.0.4/admin/PROD_scdoraprd/diag/rdbms/prod/PROD/trace/
rm alrt_tmp.log
touch alrt_tmp.log
grep -i ORA- alert_PROD.log  >> alrt_tmp.log

mv alert_PROD.log   alert_PROD.log$x

if [[ $? -eq 0 ]]; then
mailx -s "Alert log reported errors in PROD !!! "  xyz@gmail.com<alrt_tmp.log
fi

No comments: