DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Wednesday, July 29, 2015

Identification of Long running reports in 10g Oracle Application Reports.

The below script is used to identify the long running reports in 10g Oracle Application Reports.


#!/bin/bash
###############################################################################
# File Name   : long_runn_rpt.sh
# Author      : Vimal Raju
# Date        : 05/12/2015   --- MM/DD/YYYY
# Description : Long running reports
#
###############################################################################

hostName=`hostname`
LOG_LOC=/u01/app/oracle/scripts/log
logfile=${LOG_LOC}/pid.log
tmpfile=/u01/app/oracle/scripts/tmp/tmp.log
mail=dbadesk@test.com
> ${logfile}
time=$1
ltime=`expr ${time} \\* 60 \\* 60 `

ps -ef|grep engine|grep -v "grep"| awk '{print $2}' > ${tmpfile}

tmp=`cat ${tmpfile}|wc -l`
tmp1=1

while [ ${tmp1} -le ${tmp} ]
do
  ct=`cat ${tmpfile}|awk "NR=="${tmp1}""`
  test1=`stat -t /proc/${ct} | awk '{print $14}'`
  test2=`date +%s`
  test3=`expr ${test2} - ${test1}`

  if [ ${test3} -gt ${ltime} ]
  then
      echo " This process PID = ${ct} running long time in ${hostName} " >> ${logfile}
  else
      echo " "
  fi
  tmp1=`expr ${tmp1} + 1`
done

trig=`cat ${logfile}|wc -l`
check_tmp=`cat ${LOG_LOC}/report_trigger_tmp.log`

if [ "${trig}" -gt 0 ]
then
echo C > ${LOG_LOC}/report_trigger.log
elif [ "${check_tmp}" = 'T' ]
then
echo N > ${LOG_LOC}/report_trigger.log
fi

check_crit=`cat ${LOG_LOC}/report_trigger.log `
if [ "${check_crit}" = 'C' ]
then
echo " ${trig} process running long time in ${hostName} " |mailx -s "Critical : Long running reports in ${hostName}"  $mail
echo T > ${LOG_LOC}/report_trigger_tmp.log
elif [ "${check_crit}" = 'N' ]
then
echo " No long running reports in ${hostName} " |mailx -s "Normal : Long running reports in ${hostName}"  $mail
echo "" > ${LOG_LOC}/report_trigger.log
echo "" > ${LOG_LOC}/report_trigger_tmp.log
fi