Find out if a host is alive

A

Anand Pillai

I would like to add a feature to one of my network programs.
The requirement is to find out if a server is alive by sending
it requests. I know of the standard ICMP ping, and searched
for python modules able to 'PING'. The only hit I got was Jeremy
Hiltons ping package, written for Python 1.4, and it does not
work with the latest Python versions (2.0 upwards).

Are there other ways of finding out (in a few lines of code)
whether a server is alive, apart from the ICMP protocol?

Thanks for your help.

-Anand
 
A

Alex Martelli

Anand said:
I would like to add a feature to one of my network programs.
The requirement is to find out if a server is alive by sending
it requests. I know of the standard ICMP ping, and searched
for python modules able to 'PING'. The only hit I got was Jeremy
Hiltons ping package, written for Python 1.4, and it does not
work with the latest Python versions (2.0 upwards).

http://pynms.sourceforge.net/ does appear to support ICMP, among
many other things, and to support Python 2.2 (I'd be quite amazed
if it worked with 2.2 and not with 2.3).
Are there other ways of finding out (in a few lines of code)
whether a server is alive, apart from the ICMP protocol?

If you know what services the server is supposed to be running,
sure. If you have no idea whatsoever, no way. It's quite
imaginable, for example, that a server does not serve ICMP
(doesn't WANT to be pinged nor tracerouted etc) but only,
strictly HTTP on port 80/TCP _period_. If you know that, then
'pinging' the server is useless as a way to determine whether
the server 'is alive'; rather, you would try to bind a socket
to its TCP port 80, and, depending on your definition of "being
alive", might claim that just managing to bind that socket is
enough (or, you might try some short HTTP transaction on the
socket).

I've noticed an analogy between people wanting their programs
to check if "a server is alive" and ones wanting their programs
to check if "a file exists": the question they pose is rarely
the one they really need to get answered; for example, the
mere existence of a file is often of no real interest if the
program does not have permission to _read_ the file -- and
the mere "aliveness" of a host is often of no real interest
if the program does not have permission to _talk_ to the host
along at least one protocol that's of actual _use_...


Alex
 
A

Anand Pillai

Thank You Alex. What I want is actually answered by you.
I would like to find if the server is answering HTTP requests
at port 80.

I checked out pyheartbeat, but I think it is useful only for
computers in the local area network and not the internet.

-Anand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top