Need help please !!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help please !!!
# 1  
Old 06-20-2010
Need help please !!!

HI
I know that it sounds crazy Smilie
the below script checking the Database availability on many servers by establishing rsh session ( one by one ) , sometime one of the servers goes down and while this the script taking over 2 min than i got this message :
Code:
  ::ffff: 10.10.109.61: Connection refused
  ./TABSDB_check1[30]: test: argument expected

what i need it is a function to merge it with the below script to kill the established ( hanged ) rsh session after 20 seconds at least and echo "Server Down" than check the rest .

(OS : Solaris 10 )
Code:
#!/usr/bin/ksh
while true
do
clear
$NORMAL
echo `date "+%I:%M %p %a %d %b %Y"` 
echo
echo "DataBase Description                 Status " 
echo "-------------------------------------------\c"  
#$GREEN
k=1
cat TABSDB.list|while read A B C D
do
arry1[$k]=$A
arry2[$k]=$B
arry3[$k]=$C
arry4[$k]=$D
k=`expr $k + 1`
done 
##########################
RED="echo \\033[0;31m\c"
NORMAL="echo  \\033[0;39m"
GREEN="echo  \\033[0;32m\c"
BLUE="echo \\033[0;35m" 
n=1
#$GREEN
echo
while [ $n -lt $k ]
do
if [ `rsh ${arry1[$n]} "ps -ef | grep -v grep | grep "${arry3[$n]}"  2>/dev/null|wc -l " ` -gt 0 ] 
then
echo " ${arry4[$n]}`$GREEN` Running `$NORMAL`"  
else 
#$RED
echo " ${arry4[$n]}`$RED` Stopped `$NORMAL`\c"  
#$GREEN
echo
fi
n=`expr $n + 1 `
done 
sleep 15
#sleep 10
done

Moderator's Comments:
Mod Comment Please use code tags, ty
# 2  
Old 06-20-2010
Just guessing, but wouldn't it be an option to (1) make sure the server is up, e.g. by pinging it, then (2) establish a connection?
# 3  
Old 06-20-2010
what if the RSH is not available on it !? i need it for both cases to keep the script continuing checking the rest of the available database
# 4  
Old 06-20-2010
Instead of rsh'ing to a remote host you could just check if it is listening on a specific port, e.g. using netcat:
Code:
if nc -z remotehost 1521; then
  echo remotehost is listening on port 1521
fi


Last edited by Scrutinizer; 06-20-2010 at 07:22 AM..
# 5  
Old 06-24-2010
nc tool is not installed on servers Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question