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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically confirm remote server is available 1

Status
Not open for further replies.

KarveR

MIS
Dec 14, 1999
2,065
GB
I have several servers, RH ES4.

I want to be able to identify in a shell script if a remote server is unavailable.

I could use ping, but really, whats the best/preferred/most reliable / nicest way of doing this?

Just open to suggestions here on how you would go about finding this out.

thanks.

k


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
my preferred method is something like
Code:
for i in server1 server2 server3
do
  ssh $i date >/dev/null 2>&1 || mail me@myhost -s "server $i is down"
done
Of course the best way is to pay for a monitoring tool like BMC Patrol - I'm not saying it's the best - just what we use.

Columb Healy
 
Thanks man, wouldn't have thought about that at all. ended up with this.
Code:
#determine if remote mysql is available,otherwise use backup
if [ `nmap -p 3306 -T insane xxx.xxx.xxx.xxx|grep -c "1 host"` -eq 1 ] ; then
        HOST=xxx.xxx.xxx.xxx
else
        HOST=yyy.yyy.yyy.yyy
fi


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Also, if there's an Oracle database on the target machine, I usually use [tt]tnsping[/tt] too. That confirms that both the machine and the database is up and accessible.
 
SamBones
Sorry to nitpick but tnsping does not show that the database is up, merely that the listener is running. It's useful information but when I wrote a script to run status checks on all our hosts and processes the DBAs recommended that I do a simple SQL query to check that the database was up. To avoid putting passwords in scripts I ended up doing
Code:
ps -ef | grep pmon | grep <database name>
which I run under ssh.

Columb Healy
 
Hi columb, yep, you're right. I was trying to keep my reply brief and got caught!

[blush]
 
Feherke: machine state OK when ping works?

I beg to differ, I've seen servers that are still pingable, but are otherwise unreachable...

ping OK
NO rsh
NO telnet
NO console login
NO response on already logged in sessions

I'm not saying that happens a lot, but it happens.

Only way out: power off/on.


HTH,

p5wizard
 
What feherke said:
feherke said:
As usually I want to know about a service, I use nmap to check if its port is open.

this provided me with a way to determine that the port was open, this gives a better clue than ping which has been very unreliable.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Hi

p5wizard said:
machine state OK when ping works?
Of course, you are right. I saw this kind of situations myself too.

When I use [tt]ping[/tt] to check a machine, usually there are more then one to check, check is periodically and the machine is far. So when I end up with using [tt]ping[/tt], in that circumstances I prefer to ignore the situation described by you.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top