Tuesday, 26 May 2020

Crontab - Tablespace threshold Alert om mail example


######### Tablespace Threshold Alert ###################

Crontab Details:

0,15,30,45 * * * * /u04/MasterDB/scripts/daily_health_check/tablespace_threshold.ksh > /u04/MasterDB/scripts/daily_health_check/ts_alert.log  2>&1

Scripts Details:

oracle@test02:~> cat /u04/MasterDB/scripts/daily_health_check/tablespace_threshold.ksh

#!/bin/sh

export ORACLE_HOME=/u02/app/oracle/product/12.1.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=PRODB

cd /u04/MasterDB/scripts/daily_health_check

logfile=/u04/MasterDB/scripts/daily_health_check/Tablespace_alert.log

cnt1=`ps -ef|grep pmon|grep $ORACLE_SID|wc -l`

if [ $cnt1 -eq 1 ];

then

sqlplus -s "/as sysdba" > /dev/null << EOF

spool $logfile

@/u04/MasterDB/scripts/daily_health_check//tablespace_alert.sql

spool off

exit

EOF

# If there are more then these two lines in the output file, mail it.

count=`cat $logfile|wc -l`

#echo $count

if [ $count  -ge 4 ];

 then

  mailx -s "ALERT: 90 % Threshold Alert FOR PROD Database  "coredba@abc.com <$logfile

fi

fi

oracle@test02:~>

No comments:

Post a Comment