Find out if a host is alive

Discussion in 'Python' started by Anand Pillai, Oct 4, 2003.

  1. Anand Pillai

    Anand Pillai Guest

    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
    Anand Pillai, Oct 4, 2003
    #1
    1. Advertising

  2. Anand Pillai wrote:

    > 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
    Alex Martelli, Oct 4, 2003
    #2
    1. Advertising

  3. Anand Pillai

    Anand Pillai Guest

    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

    Alex Martelli <> wrote in message news:<ccCfb.224602$>...
    > Anand Pillai wrote:
    >
    > > 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
    Anand Pillai, Oct 5, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Orpheus66
    Replies:
    0
    Views:
    4,426
    Orpheus66
    Jul 30, 2003
  2. Robert Brewer

    RE: Find out if a host is alive

    Robert Brewer, Oct 4, 2003, in forum: Python
    Replies:
    0
    Views:
    398
    Robert Brewer
    Oct 4, 2003
  3. Jerry Qu
    Replies:
    1
    Views:
    472
    lee atkinson
    Feb 20, 2009
  4. Wybo Dekker
    Replies:
    1
    Views:
    353
    Yukihiro Matsumoto
    Nov 15, 2005
  5. hisan
    Replies:
    1
    Views:
    1,319
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page