# Database Server Monitoring Script [dbalarm].
VER=”[6.3]”
SCRIPT_NAME=”dbalarm${VER}”
# Features:
# Report ERRORS in DB, ASM Instance, GRID INFRASTRUCTURE, GOLDENGATE and LISTENERS ALERTLOG plus dmesg DEVICE DRIVER OS log.
# Report TABLESPACES, ASM DISKGROUPS and FRA when reach %USED THRESHOLD.
# Report OFFLINE databases.
# Report CPU, FILESYSTEM, TABLESPACES When hit the THRESHOLD.
# Report LONG RUNNING operations/Active SESSIONS on DB when the CPU hits the THRESHOLD.
# Report BLOCKING SESSIONS in the database.
# Report Failed RMAN Backup Jobs.
# Report User Defined DATABASE SERVICES when they go OFFLINE.
# Notes:
# Most of THRESHOLD and CONTROLS in this script located under THRESHOLDS section. Please adjust them to meet your needs.
# ###########################################################################################################################################
# Modified: 23-12-13 Handled non exist logs 1run
# 14-05-14 Handled non existance of LOG_DIR directory.
# 18-05-14 Add Filsystem monitoring.
# 19-05-14 Add CPU monitoring.
# 03-12-14 Add Tablespaces monitoring
# 08-09-15 mpstat output change in Linux 6
# 02-04-16 Using dba_tablespace_usage_metrics To calculate MAXSIZE (11g onwards) Recommended by Satyajit Mohapatra.
# 10-04-16 Add Flash Recovery Area monitoring.
# 10-04-16 Add ASM Disk Groups monitoring.
# 15-09-16 Add “DIG MORE” feature to report.long running operations, queries
# and active sessions on DB side when CPU hits the pre-defined threshold.
# 29-12-16 Enhanced ORACLE_HOME search criteria.
# 02-01-17 Added EXL_DB parameter to allow the user to exclude DBs from having dbalarm script run against.
# 04-05-17 Added the ability to disable Database Down Alert through CHKOFFLINEDB variable.
# 11-05-17 Added the option to exclude tablespace/ASM Diskgroup from monitoring.
# 11-05-17 Tuned the method of reporting OFFLINE databases & checking listener log.
# 20-07-17 Modified COLUMNS env variable to fully display top command output.
# Neutralize login.sql if found in Oracle user home directory due to bugs.
# 19-10-17 Added the function of checking goldengate logfile.
# 11-04-18 Added the feature of monitoring the availability of specific service.
# 28-04-18 Added the function of printing the script progress.
# 30-04-18 Added Paranoid mode, to report EXPORT/IMPORT, ALTER SYSTEM, ALTER DATABASE
# instance STARTUP/SHUTDOWN, other DB Major activities.
# 05-09-18 Modified the wait in seconds column (Blocking Sessions section) for 11gr2 compatibility,
# Added WAIT_FOR_LOCK_THRES threshold to control reporting of sessions blocked for more than N mintes.
# 09-10-18 Enclosing OS Network Failure Statistics (Dropped Packets) whenever TIMOUT error get reported by DB or Listener.
# 15-10-18 Added RMAN Backup Failure Check. [Recommended by: Rahul Malode]
# 22-10-18 Added the Checking of Running RMAN Backup when CPU hit the threshold.
# 01-11-18 Fixing a bug in Monitored Services section.
# 08-11-18 Show the exist restore points if FRA hits the threshold.
# 27-12-18 Checking if another session is running dbalarm script [to avoid performance degradation].
# 14-01-19 Avoid Monitoring the Services if more than one DB instance is running.
# 15-01-19 Added the feature of monitoring the ASM instance ALERTLOG.
# 15-01-18 Added the feature of monitoring the GRID INFRASTRUCTURE ALERTLOG.
# 16-01-19 Added the feature of monitoring Device Driver OS log “dmesg”.
# 04-02-19 Added HTML feature to send the alert in HTML format [If sendmail installed, otherwise will use TEXT format automatically].
#
#
# ######################################################################################################################################################
EMAIL=”youremail@yourcompany.com”
export SRV_NAME=”`uname -n`”
# Check if MAIL_LIST parameter is not set notify the user and exit:
case ${EMAIL} in “youremail@yourcompany.com”)
echo
echo “******************************************************************”
echo “Buddy! You forgot to edit line# 60 in dbalarm.sh script.”
echo “Please replace youremail@yourcompany.com with your E-mail address.”
echo “******************************************************************”
echo
echo “Script Terminated !”
echo
exit;;
esac
# Check if there is another session of dbalarm is running: [Avoid performance impact]
DBALARMCNT=`ps -ef|grep -v grep|grep -v vi|grep dbalarm|wc -l`
if [ ${DBALARMCNT} -gt 2 ]
then
echo -e “