Tuesday, November 29, 2011

Shell script to poll database and send an alert email

export ORACLE_HOME="/u000/app/oracle/product/112/db2"
export ORACLE_SID=orcl

a=`$ORACLE_HOME/bin/sqlplus -s /nolog << EOF
connect dev_mds/welcome123
set heading off
select count(report) from common_logs
where report='failed'
exit;
EOF`

echo count: $a

if test $a -eq 0
then
echo $a > /home/oracle/mess_count
/bin/mailx -s "ALERT: For BEA-382502 !!! " abc@abc.com < /home/oracle/mess_count

No comments: