Script to Monitor Database Instance and Listener

3
#Script to monitor Database instance and Listener ############################################### #Set The Databse Environment ############################################### . $HOME/.bash_profile #ReportFile=/tmp/Services_Summary_Report.log rm -rf /tmp/Services_Summary_Report.log ################################################### #Check For The Avilability of Database ################################################## ps -ef|grep smon|grep ${ORACLE_SID}| grep -v grep >/tmp/Services_Report.log if [ `ps -ef | grep smon | grep ${ORACLE_SID} | grep -v grep | wc -l` -lt 1 ]; then echo "Oracle Database : ${ORACLE_SID} Host : `hostname` Status : Down" >$ReportFile else echo "Oracle Database : ${ORACLE_SID} Host : `hostname` Status : Database is Up" >>/dev/null fi ################################################## #Check For The Avilability Of Listener ################################################## ps -ef|grep tnslsnr|grep ${ORACLE_SID}| grep -v grep >/tmp/Services_Report.log if [ `ps -ef | grep tnslsnr | grep ${ORACLE_SID} | grep -v grep | wc -l` -lt 1 ]; then echo "Oracle Listener : ${ORACLE_SID} Host : `hostname` Status : Down" >>$ReportFile mailx -s $ORACLE_SID" Database and Listener Status Report"`date '+%m%d'` [email protected] <$ReportFile else echo "Oracle Listener : ${ORACLE_SID} Host : `hostname` Status : Listener is UP" >>/dev/null if [ -f $ReportFile ]; then mailx -s $ORACLE_SID" Database and Listener Status Report"`date '+%m%d'` [email protected]<$ReportFile else echo "File $ReportFile does not exists">>/dev/null fi fi Locks select l1.sid, ' IS BLOCKING ', l2.sid from v$lock l1, v$lock l2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2; 2 3 4 5

description

Script to monitor Database instance

Transcript of Script to Monitor Database Instance and Listener

Page 1: Script to Monitor Database Instance and Listener

#Script to monitor Database instance and Listener

################################################Set The Databse Environment###############################################. $HOME/.bash_profile#ReportFile=/tmp/Services_Summary_Report.logrm -rf /tmp/Services_Summary_Report.log####################################################Check For The Avilability of Database##################################################ps -ef|grep smon|grep ${ORACLE_SID}| grep -v grep >/tmp/Services_Report.log if [ `ps -ef | grep smon | grep ${ORACLE_SID} | grep -v grep | wc -l` -lt 1 ]; then echo "Oracle Database : ${ORACLE_SID} Host : `hostname` Status : Down" >$ReportFile else echo "Oracle Database : ${ORACLE_SID} Host : `hostname` Status : Database is Up" >>/dev/null fi###################################################Check For The Avilability Of Listener##################################################ps -ef|grep tnslsnr|grep ${ORACLE_SID}| grep -v grep >/tmp/Services_Report.log if [ `ps -ef | grep tnslsnr | grep ${ORACLE_SID} | grep -v grep | wc -l` -lt 1 ]; then echo "Oracle Listener : ${ORACLE_SID} Host : `hostname` Status : Down" >>$ReportFile mailx -s $ORACLE_SID" Database and Listener Status Report"`date '+%m%d'` [email protected] <$ReportFile else echo "Oracle Listener : ${ORACLE_SID} Host : `hostname` Status : Listener is UP" >>/dev/null if [ -f $ReportFile ]; then mailx -s $ORACLE_SID" Database and Listener Status Report"`date '+%m%d'` [email protected]<$ReportFile else echo "File $ReportFile does not exists">>/dev/null fi fi

Locksselect l1.sid, ' IS BLOCKING ', l2.sidfrom v$lock l1, v$lock l2where l1.block =1 and l2.request > 0and l1.id1=l2.id1and l1.id2=l2.id2;  2    3    4    5       SID 'ISBLOCKING'         SID---------- ------------- ----------      3251  IS BLOCKING        3001select sid, b.serial#, osuser, b.username, status, process, paddr, spid, b.last_call_et/60from v$process a,v$session bwhere sid = '&sid'and a.addr = b.paddr

Page 2: Script to Monitor Database Instance and Listener

and b.username != ' 'order by 1/             

select sid, program, module, action, last_call_et, status from v$session where sid = &sid;

alter system kill session '

Concurrent Manager

#!/bin/sh

### check concurrent managers up/down### 10,20,30,40,50,00 * * * * . /home/applprod/scripts/check_ccm.sh >> /home/applprod/scripts/logs/check_ccm.log 2>&1

. /home/applprod/.bash_profile

$FND_TOP/bin/FNDSVCRG STATUS> /home/applprod/scripts/logs/ccmstatus.log

if [ `cat /home/applprod/scripts/logs/ccmstatus.log |grep -i not |wc -l` -gt 0 ];then ##mail -s "Concurrent Manager is down for ${TWO_TASK}" "[email protected]" echo "ICM is not up on `hostname -s`" | mailx -s "Alert : Concurrent Manager is down for FIJI PRODUCTION Server `hostname -s`" "[email protected]"fiSELECT component_name, component_status FROM fnd_svc_components WHERE component_type = 'WF_MAILER'; ======================================================================================================================#!/bin/sh### check apache server up/down### 10,20,30,40,50,00 * * * * . /home/applprod/scripts/check_apache.sh >> /home/applprod/scripts/logs/check_apache.log 2>&1. /home/applprod/.bash_profile

$INST_TOP/admin/scripts/adapcctl.sh statusif [ $? = 0 ];then echo " Apache is up" #echo " Apache is up on `hostname -s`"| mailx -s "Apache is up for FIJI PRODUCTION Server `hostname -s`" "[email protected]"else # echo "Apache is not up, Sending email" echo "Apache is down on `hostname -s`"| mailx -s "Alert : Apache is down for FIJI PRODUCTION Server `hostname -s`" "[email protected]" # echo "Apache is not up, Sending email" | mailx -s "Apache is down for ${TWO_TASK}" "[email protected]"Fi

Page 3: Script to Monitor Database Instance and Listener

find ICM log on Oracle Apps 11i and R12?

SELECT 'ICM_LOG_NAME=' || fcp.logfile_name

FROM fnd_concurrent_processes fcp, fnd_concurrent_queues fcq

WHERE fcp.concurrent_queue_id = fcq.concurrent_queue_id

AND fcp.queue_application_id = fcq.application_id

AND fcq.manager_type = '0'

AND fcp.process_status_code = 'A';