Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

monitoring script

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
US
Am attempting to write a script that will monitor some oracle processes. I have a file that it read from that only contains the following two lines:(The filename is oradbproc2.lis). I am running the script from the SP control workstation using the dsh command. Can someone please help me troubleshoot why it is not working. Probably syntax but don't know. Thanks


sp18cw:tnslsnr TRN::The TRN DB Listener process on SP18 is down:
sp18cw:FNDLIBR:appltrn:The TRN Concurrent Manager process on SP18 is down:

My script looks like this:

#!/bin/ksh
##
for line in `cat /bin/danka/oradbproc2.lis`
do
SERVER=`echo "$line"|cut -f 1 -d :`
PROC=`echo "$line"|cut -f 2 -d :`
USER=`echo "$line"|cut -f 3 -d :`
MAILMSG=`echo "$line"|cut -f 4 -d :`
RC=1

ping -c 5 ${SERVER} 1>/dev/null 2>/dev/null
if [ $? = 1 ]
then
clear
echo "\n\n\n"
echo "Server: ${SERVER} is not available......\n"
echo "Contact UNIX Support.....\n\n\n"
set $RC=0
else
dsh -w ${SERVER} ps -ef |grep -i "${PROC}" |grep ${USER} |grep -v grep
if [ $? = 1 ]
then
$MAILMSG|mail -s ORACLE ALERT 4556720@archwireless.net
set $RC=0
fi
fi
done
 
Hi:

I've never used dsh, but how can you be sure if your ping command fails that the exit code, $?, is 1? If I were doing it, I'd check for the exit code equal zero if ping worked.

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top