#!/bin/bash
###############################################################################
# File Name : long_runn_forms.sh
# Author : Vimal Raju
# Date : 04/11/2018 --- MM/DD/YYYY
# Description : Long running forms
#
###############################################################################
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 frm|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}/form_trigger_tmp.log`
if [ "${trig}" -gt 0 ]
then
echo C > ${LOG_LOC}/form_trigger.log
elif [ "${check_tmp}" = 'T' ]
then
echo N > ${LOG_LOC}/form_trigger.log
fi
check_crit=`cat ${LOG_LOC}/form_trigger.log `
if [ "${check_crit}" = 'C' ]
then
echo " ${trig} process running long time in ${hostName} " |mailx -s "Critical : Long running forms in ${hostName}" $mail
echo T > ${LOG_LOC}/form_trigger_tmp.log
elif [ "${check_crit}" = 'N' ]
then
echo " No long running forms in ${hostName} " |mailx -s "Normal : Long running forms in ${hostName}" $mail
echo ""> ${LOG_LOC}/form_trigger.log
echo ""> ${LOG_LOC}/form_trigger_tmp.log
fi
###############################################################################
# File Name : long_runn_forms.sh
# Author : Vimal Raju
# Date : 04/11/2018 --- MM/DD/YYYY
# Description : Long running forms
#
###############################################################################
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 frm|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}/form_trigger_tmp.log`
if [ "${trig}" -gt 0 ]
then
echo C > ${LOG_LOC}/form_trigger.log
elif [ "${check_tmp}" = 'T' ]
then
echo N > ${LOG_LOC}/form_trigger.log
fi
check_crit=`cat ${LOG_LOC}/form_trigger.log `
if [ "${check_crit}" = 'C' ]
then
echo " ${trig} process running long time in ${hostName} " |mailx -s "Critical : Long running forms in ${hostName}" $mail
echo T > ${LOG_LOC}/form_trigger_tmp.log
elif [ "${check_crit}" = 'N' ]
then
echo " No long running forms in ${hostName} " |mailx -s "Normal : Long running forms in ${hostName}" $mail
echo ""> ${LOG_LOC}/form_trigger.log
echo ""> ${LOG_LOC}/form_trigger_tmp.log
fi