Oracle database blocking script and send mail alerts in Linux Platform

Database blocking script and send mail Alerts in Linux Platform

Scripts is made for Linux and Unix platform using bash shell programming.
You can simple copy paste and change mail id and set environment variable for ORACLE_SID, User name and system password it ready to use.

Scripts for scheduling in Linux crontab:

#!/bin/bashSSH_CMD="ssh"

LOG_F="/u01/app/orash/script/monitor/log/detect_blockers_one.log"
LOG_A="/u01/app/orash/script/monitor/log/detect_blockers_one_akkumulert.log"
MAIL_TO_1=mail@gmail.com,mail2@gmail.com
MAIL_TO_2=mail3@gmail.com
ALERT_LOG=/u01/app/orash/11g/admin/alert_dbname.log

. $HOME/.profile

# Configurable parameters
#BLOCK_TIME_LIMIT=${BLOCK_TIME_LIMIT:-900}
BLOCK_TIME_LIMIT=${BLOCK_TIME_LIMIT:-180}
WAIT_TIME_LIMIT=${WAIT_TIME_LIMIT:-3600}

function check_blockers
{

# Find current run-status of all components
env_desc="$ORACLE_SID environment"
sid=$ORACLE_SID

# Find blockers
BLOCKERS=`cat > /dev/null && e
cho 'HZ_DQM_SYNC'`" ]; then
warning "##############################################"
warning "$env_desc has the following blocking conditions:"
warning "##############################################"
warning "$BLOCKERS"
echo "$BLOCKERS" > $LOG_F
echo "$BLOCKERS" >> $LOG_A
/bin/mailx -s "SHPROD (PROD)has the following blocking conditions:" $MAIL_TO_1 > $ALERT_LOG
else
info "##############################################"
info "$env_desc has no blocking locks idle longer than $BLOCK_TIME_LIMIT seconds"
fi
fi

# Find blockers
BLOCKERS=`cat > /dev/null && e
cho 'HZ_DQM_SYNC'`" ]; then
#if [ "$BLOCKERS" != "" ]; then
warning "##############################################"
warning "$env_desc has the following waiting sessions:"
warning "##############################################"
warning "$BLOCKERS"
echo "$BLOCKERS" > $LOG_F
echo "$BLOCKERS" >> $LOG_A
#   /bin/mailx -s " (PROD) has the following waiting sessions:" $MAIL_TO_2 < $LOG_F
else
info "$env_desc has no waiting sessions idle longer than $WAIT_TIME_LIMIT seconds"

fi
fi

}

if [ "$#" -ne 0 ]; then
error "Usage: $0"
exit 1
fi

info "##############################################"
info "STARTING"
info "Fetching credentials from \$HOME/.xxcu_passwordfile"
SYSTEM_PWD=$(obtainPasswordFromFile SYSTEM)
check_blockers

info "##############################################"
info "COMPLETED"
info "##############################################"

exit 0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.