Wednesday, 23 September 2015

Check DATABASE Login before proceeding



########## Check to login before proceeding ##################

DBCHECK=/tmp/${ORACLE_SIDD}_check.log
SQL1="SELECT SYSDATE FROM DUAL";
sqlplus -s "$USERID/$PASSWORD@$CONNECT" <<-EOT > ${DBCHECK}
set heading off
set feedback off
${SQL1};
exit;
EOT


if [ $(cat ${DBCHECK}|grep "ORA-"|wc -l) -gt 0 ]; then
        echo "Sorry Login issues with the database ${ORACLE_SIDD}".

        message="[CRITICAL] [IB Messages Monitor: ${ORACLE_SID} DATABASE LOGIN FAILED] [${HOST_NAME}]"
        /bin/mailx -s "$message" -r noreply@prologis.com ${MAILLIST}  <<-EOFL

                Hi PSFT ADMIN Team,

                asynchronous_error_monitor.sh script for Production

                Sorry, there was a problem in logging to the ${ORACLE_SIDD} Database. So, can not continue to check for asynchronous errors.
                Please do fix this issue on Priority. Escalate to the DBA Manager for any serious concerns.

                ______________________________________________________________________________________________
                Oracle Database Availability Status Report: ps -efx|grep pmon
                ----------------------------------------------------------------------------------------------
                $(ps -efx|grep pmon)
                ______________________________________________________________________________________________

                ______________________________________________________________________________________________
                Database Login ERROR Logs
                ----------------------------------------------------------------------------------------------
                $(cat ${DBCHECK})
                ______________________________________________________________________________________________


                ______________________________________________________________________________________________
                Please check the following for user ID: ${USERID}
                ----------------------------------------------------------------------------------------------
                1) Please check login credentials
                2) Check If the user account has been locked / expired
                2) Check DB Wallets are open and allowing the logins
                3) Check if the listeners and database are up and available.
                ______________________________________________________________________________________________

                Note: Ignore this email if the DBA has intentionally stopped the ${ORACLE_SIDD} database for maintenance activities.

If you don't want to see this alert email again. Please remove the entry from the crontab on ${HOST_NAME} host.
Only do this once you have necessary approvals from the DBA Manager.


==============================================================================
Asynchronous error Monitoring script
==============================================================================
This script is located in the directory $(cd $(dirname $0);echo $PWD)
Host Name : $HOST_NAME
Script Name : "${0##*/}"
Version  : 2.0
Script Author : "PwC Env Team"
===============================================================================

Thanks
I am back on Job.


EOFL
exit 1;

else
echo "I am good. The database is up and available";
fi
######################################



No comments:

Post a Comment