Find the remote server status.

Hi All,

I would like to connect from "Instance A" to "Instance B" with the help of sftp.
Where as Instance B is having clustered servers ( 2 servers pointing same instance ).

Now, my question is before connecting to "Instance B" from "Instance A" how do know whether server is running or not. Based on which i can connect to the running server ignoring the server which is down.

Note :: Both A and B are UNIX servers. While B is clustered.

Please help me with the best approach.

Hello,

I think that you doesn�t need to check before connect, only you shoutd "atack" to cluster IP, instead to the servers.

Simple...ping by IP address. Let the cluster worry about the actual node you attach to in the case of B. Unless you can ping the unique IP addresses of the nodes that comprise the cluster (this of course depends on how the ip address is "shared" on the cluster nodes; i.e. round-robin) .

You can test the success/failure of the ping or the sftp (the ping is probably faster to give results since you can control it with a -c Count and -w timeout options). I would also trust ping more so than sftp for returning status of failure or success.

So you can do something like...

if ping -q -c3 -w 3 A
then
  sftp .... to A
else if ping -q -c3 -3 5 B
then
 sftp to B
else
 echo "Failed to sftp to either A or cluster B"
fi 

or suppose you can ping the unique addresses of cluster B, say B1 and B2 (make sure you can, because cluster nodes unique ip addresses could be on a different segment depending on the cluster)...not really different...

if ping -q -c3 -w3 A
then
  sftp .... to A
else if ping -q -c3 -w3 B1
then
 sftp... to B1
else if else if ping -q -c3 -w3 B2 
 sftp... to B2
else
 echo "Failed to sftp to either A or B1 or B2"
fi 

I did not test this but you should be able to get the idea.

If the requirement is to work on the application supported by the cluster and you have a shared IP address that the cluster serves, then it should not matter where you actually attach to. The updates should be to common disk. If the cluster IP address is not responding then you have bigger problems.

If you need to connect to each server for an infrastructure reason that is outside the application that the cluster is serving, then use the persistent host specific IP addresses.

Robin