The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How ls | wc -l works? krishmaths UNIX for Dummies Questions & Answers 3 04-11-2008 01:16 PM
Works with FTP but not NFS pbonilla UNIX for Dummies Questions & Answers 1 01-08-2008 02:31 PM
how domain name reg works vutty81 IP Networking 4 11-20-2007 03:00 PM
how i prepare a c++ code(c code) for implementing my own protocol format amitpansuria High Level Programming 1 09-06-2007 08:09 PM
SSH key code versus server key code Texan Security 1 04-12-2006 08:57 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-06-2006
Registered User
 

Join Date: Apr 2006
Posts: 2
Code works sometimes and sometimes not

The following script works sometimes and sometimes not. I am not able to troubleshoot what the problem is ?
Code:
cd ~
. $HOME/.profile

# Orasid.lst has the DB name which I want to Monitor
# Oratab has all the database names on the srver

cat $ORA_SCRIPT/orasid.lst | while read LINE1
do
  cat /etc/oratab | while read LINE
  do
  case $LINE in
  \#*)            ;;      #comment-line in oratab
  *)
  #       Proceed only if third field is 'Y'.
 if [ "`echo $LINE | awk -F: '{print $1}' -`" = $LINE1 ] ; then
 export ORACLE_SID=$LINE1
 export ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`

#
# CHECK FOR ALL DB if Up/Down
#

  if [ -f $ORA_LOG/pmon_process_exist.txt ] ; then /bin/rm $ORA_LOG/pmon_process_exist.txt; fi
  ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep  > $ORA_LOG/pmon_process_exist.txt
  if [ -s $ORA_LOG/pmon_process_exist.txt ]
  then
        if [ -f $ORA_SCRIPT/select.lst ] ; then /bin/rm $ORA_SCRIPT/select.lst; fi
        $ORACLE_HOME/bin/sqlplus -s ora_connect/ora_connect@$ORACLE_SID @$ORA_SCRIPT/select.sql
        if [ -s $ORA_SCRIPT/select.lst ]
        then
                echo "DB ALL OK"
        else
        for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
        do
                /usr/bin/mailx -s "PMON is up but DATABASE HAS CONNECTIVITY ISSUES: $ORACLE_SID" $dba < /dev/null
        done
        fi
  else
    for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
    do
        /usr/bin/mailx -s "DATABASE IS DOWN: $ORACLE_SID" $dba < /dev/null
    done
  rm $ORA_LOG/pmon_process_exist.txt
  fi
 fi
esac
done
done
Can someone tell me why even if the file "$ORA_LOG/pmon_process_exist.txt" exist the code goes to the else stmt (only few times not always).

Code:
if [ -s $ORA_LOG/pmon_process_exist.txt ]
  then
        if [ -s $ORA_SCRIPT/select.lst ]
        then
                echo "DB ALL OK"
        else
        for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
        do
                /usr/bin/mailx -s "PMON is up but DATABASE HAS CONNECTIVITY ISSUES: $ORACLE_SID" $dba < /dev/null
        done
        fi
else
    for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
    do
        /usr/bin/mailx -s "DATABASE IS DOWN: $ORACLE_SID" $dba < /dev/null
    done
  rm $ORA_LOG/pmon_process_exist.txt
  fi
So I get an email only 2 or 3 times out of 20 times it runs as a cronjob.
Even if
"ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep > $ORA_LOG/pmon_process_exist.txt" generates the file.
Reply With Quote
Forum Sponsor
  #2  
Old 04-06-2006
Registered User
 

Join Date: Apr 2006
Posts: 2
Also could someone tell me the different
between
if [ -s $ORA_LOG/pmon_process_exist.txt ]
and
if [ -f $ORA_LOG/pmon_process_exist.txt ]
Reply With Quote
  #3  
Old 04-06-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
Quote:
Originally Posted by hp-aix-lnx-user
Also could someone tell me the different
between
if [ -s $ORA_LOG/pmon_process_exist.txt ]
and
if [ -f $ORA_LOG/pmon_process_exist.txt ]
'man test'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0