Iam bit poor in shell scripting,
Here my requirement is for generating an alert where the oracle database db_recovery_file_dest_size usage. If it reaches beyond 80% should recieve an alert through an email.
Want to schedule this alert in cron.
#!/bin/bash
. /home/oracle/prod.env
echo " "
echo =======================================================================
echo archive_usage.sh: $ORACLE_SID
echo To know the Archive/Db_recovery_area usage
date +"%A, %B %e, %r"
echo -----------------------------------------------------------------------
status=$(sqlplus -S system/PWD@$ORACLE_SID << ENDINP
set feedback off
set hea off
set verify off
SELECT METRIC_VALUE FROM SYS.DBA_OUTSTANDING_ALERTS where reason like '%db_recovery_file_dest_size%'
/
exit
ENDINP)
status=`echo $status`
echo "Archive Area usage is:" $status
if [ $status >= 80 ]; then
mailx -s "PROD - Archive Area Usage is growing" "mjcprasad2000@gmail.com"
Production PROD ARCHIVE Area is above 85%!!
exit 1
else
mailx -s "PROD - Not in Thresholds" "mjcprasad2000@gmail.com"
exit 0
fi
Before you said you had an issue (and didn't say what it was other than that you were trying to run your script in cron); now you're saying you're getting an error. Exactly what error(s) are you seeing?
=======================================================================
archive_usage.sh: prod
To know the Archive/Db_recovery_area usage
Friday, April 19, 01:26:30 PM
-----------------------------------------------------------------------
Archive Area usage is: Elapsed: 00:00:00.29
archive_usage.sh: line 23: [: 00:00:00.29: binary operator expected
I have already mentioned in the subject stating
---------- Post updated at 03:41 PM ---------- Previous update was at 03:29 PM ----------