Check oracle databse Job status and send email

posted Feb 12, 2012, 8:26 PM by Sachchida Ojha   [ updated Feb 12, 2012, 8:27 PM ]
monitorjobs.sh

 
#!/bin/bash
SCRIPT_FILE_HOME=/export/home/oracle/scripts/utils; export SCRIPT_FILE_HOME
SCRIPT_LOGS_HOME=/export/home/oracle/scripts/utils; export SCRIPT_LOGS_HOME
#
DATE_SUFFIX=`date '+%m-%d-%y:%r'`
for sid in $*
do
ORACLE_SID=$sid
output=`sqlplus -s "/ as sysdba" <<EOF
set heading off
set feedback off
set verify off
spool $SCRIPT_LOGS_HOME/failedjobs$sid.txt
select what,broken from dba_jobs where broken='Y';
exit
EOF
`
if [ `cat failedjobs$sid.txt|wc -l` -gt 0 ]
then
        mailx -s "$sid database one or more jobs failed!!!" mailto:support@dbaref.com < $SCRIPT_LOGS_HOME/failedjobs$sid.txt
fi
done
 
 
checkjobstat.sh ---- put it into crontab
 
#************************************************************************
#
#      File Name:     checkjobstat.sh
#      Author:        Sachchida Ojha
#      History:       02/11/2012
#
#      Explanation:   check database status amd email results
#      Parameter:     dbname
#************************************************************************
#
#!/usr/bin/bash
SCRIPT_FILE_HOME=/export/home/oracle/scripts/utils; export SCRIPT_FILE_HOME
SCRIPT_LOGS_HOME=/export/home/oracle/scripts/utils; export SCRIPT_LOGS_HOME
DATE_SUFFIX=`date '+%m-%d-%y:%r'`
$SCRIPT_FILE_HOME/monitorjobs.sh sid-list>$SCRIPT_LOGS_HOME/dbsever-jobstat.txt

Comments