#!/bin/bash
#################################################################################### Script Name : WorkflowStatusCheck.sh ## ## Description: ## Script to check workflow mailer service components status and ## to send alert notification if one or more workflow mailer components are down ## ## Usage : sh <script_name> <ORACLE_SID> ## For example : sh WorkflowStatusCheck.sh ORCL ## ## Created by : Kiran Jadhav - (https://h2hdba.blogspot.com) ##################################################################################### Initialize variablesINSTANCE=$1HOST_NAME=`hostname`PROGRAM=`basename $0 | cut -d'.' -f1`export DBA_SCRIPTS_HOME=$HOME/DBA_MONAPPS_ID=`echo$INSTANCE | tr '[:lower:]''[:upper:]'`LOG_DIR=$DBA_SCRIPTS_HOME/logs/$HOST_NAMEOUT_FILE=$LOG_DIR/`echo$PROGRAM`_$APPS_ID.html.out LOG_FILE=$LOG_DIR/`echo$PROGRAM`_$APPS_ID.log ERR_FILE=$LOG_DIR/`echo$PROGRAM`_$APPS_ID.err LOG_DATE=`date`# Source the env. $HOME/.bash_profile . $DBA_SCRIPTS_HOME/.sysenv if[$? -ne 0 ]; thenecho"$LOG_DATE"> $LOG_FILEecho"Please pass correct environment : exiting the script \n">> $LOG_FILEcat $LOG_FILEexitfiif[ -s $OUT_FILE]; thenecho"$LOG_DATE"> $LOG_FILEecho"Deleting existing output file $OUT_FILE">> $LOG_FILE rm -f $OUT_FILEcat $LOG_FILEfi# If there is a planned downtime then create $ORACLE_SID.down file in $DBA_SCRIPTS_HOME to silent the alerts during maintenance window.if[ -f $DBA_SCRIPTS_HOME/`echo$ORACLE_SID`.down ]; thenecho"$LOG_DATE">> $LOG_FILEecho"Host: $HOST_NAME | Instance: $ORACLE_SID is under maintenance: exiting the script">> $LOG_FILEcat $LOG_FILEexitfiif[$DOWNTIME_MODE="Y"]; thenecho"$LOG_DATE">> $LOG_FILEecho"Host: $HOST_NAME | Instance: $ORACLE_SID is under maintenance: exiting the script">> $LOG_FILEcat $LOG_FILEexitfi usage(){echo"$LOG_DATE"> $LOG_FILEecho"Script To Check Workflow Mailer Components Status">> $LOG_FILEecho"Usage : sh <script_name> <ORACLE_SID> ">> $LOG_FILEecho"For example : sh $PROGRAM.sh $ORACLE_SID">> $LOG_FILEecho}if[$# -lt 1 ]||["$INSTANCE" !="$ORACLE_SID"]; thenusage echo"Error : Insufficient arguments.">> $LOG_FILEcat $LOG_FILEexitfi get_count(){ sqlplus -s '/as sysdba'<<! set heading off set feedback off select count(1) from (select component_id, startup_mode,component_status,component_type,component_name from applsys.fnd_svc_components where component_status <> 'RUNNING' order by component_id ); exit; ! }count=`get_count`#echo $countecho"$LOG_DATE"> $ERR_FILEget_count >> $ERR_FILEERR_COUNT=`grep "ORA-"$ERR_FILE |wc -l`if[$ERR_COUNT -gt 0 ]; thencat $ERR_FILE | mailx -s "<ERROR> Critical : $APPS_ID - Workflow Mailer Components are DOWN on $HOST_NAME "$DBA_EMAIL_LISTexitfiif[$count -gt 0 ]; thensqlplus -s '/as sysdba'<<EOF SET ECHO OFF SET pagesize 1000 set feedback off set lines 180 SET MARKUP HTML ON SPOOL ON - HEAD '<title></title> -<style type="text/css"> - table { background: #eee; } - th { font:bold 10pt Arial,Helvetica,sans-serif; color:#b7ceec; background:#151b54; padding: 5px; align:center; } - td { font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding: 5px; align:center; } -</style>' TABLE "border='1' align='left'" ENTMAP OFF spool $OUT_FILE PROMPT Hi Team, PROMPT PROMPT Logon on to OAM (Oracle Applications Manager) and make sure the following processes are running, if not restart them. PROMPT select component_id, startup_mode,component_status,component_type,component_name from applsys.fnd_svc_components where component_status <> 'RUNNING' order by component_id; SPOOL OFF SET MARKUP HTML OFF exit;EOF(echo"To: $DBA_EMAIL_LIST"echo"MIME-Version: 1.0"echo"Content-Type: multipart/alternative; "echo' boundary="PAA08673.1018277622/server.xyz.com"'echo"Subject: Critical : $APPS_ID - Workflow Mailer Components are DOWN on $HOST_NAME "echo""echo"This is a MIME-encapsulated message"echo""echo"--PAA08673.1018277622/server.xyz.com"echo"Content-Type: text/html"echo""cat $OUT_FILEecho"--PAA08673.1018277622/server.xyz.com") | /usr/sbin/sendmail -t echo"`date`"> $LOG_FILEecho"Details sent through an email">> $LOG_FILEcat $LOG_FILEelse echo"`date`"> $OUT_FILEecho"Workflow Mailer Components are up and running fine">> $OUT_FILEfi
↧
Script to check workflow mailer service components status and send notification if DOWN
↧