![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
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
Even if "ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep > $ORA_LOG/pmon_process_exist.txt" generates the file. |
| Forum Sponsor | ||
|
|
|
#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 ] |
|
#3
|
||||
|
||||
|
Quote:
|
||||
| Google The UNIX and Linux Forums |