Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > socket.gethostbyaddr() question

Reply
Thread Tools

socket.gethostbyaddr() question

 
 
Harlin Seritt
Guest
Posts: n/a
 
      01-15-2006
I have a list of IP addresses I am testing with socket.gethostbyaddr().
For the most part, I am able to get a hostname returned to me when I
run gethostbyaddr(). I am also hoping this will allow me to tell if a
computer is up or down. However, in my environment, I am finding that I
am able to get a hostname even though I am unable to actually ping that
server (when I ping a server i like this, I get 'request timed out'
messages telling me that the server is not up).

Other times, I am able to ping a server with success but the
gethostbyaddr() request will not be able to return a hostname for me
making me think that machine is truly down when I know it's not. Can
anyone give me any pointers as to why this happens? Is there anyway I
can do a reliable ping to another server with Python? I am not
interested in doing system calls with a system Ping client (I have to
ping way too many machines and this either takes too long or causes
severe memory leakage due to MS's horrible ping client). Also, I am
unable to use Jeremy Hylton's Python ping client because it does little
more than call gethostbyaddr(). Thanks for taking a look at this.

Harlin Seritt

 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      01-15-2006
"Harlin Seritt" <> wrote:
> I have a list of IP addresses I am testing with socket.gethostbyaddr().
> For the most part, I am able to get a hostname returned to me when I
> run gethostbyaddr(). I am also hoping this will allow me to tell if a
> computer is up or down.


Gethostbyaddr() simply does a lookup in some sort of name resolution
database (typically DNS, but could be YP/NIS, hostfile, etc). The ability
to look a name up in the database has absolutely no correlation with
whether that node is up, down, or unreachable.

To tell if a machine is up or down, you need to probe the machine directly.
Typically, this is done by sending it an ICMP Echo Request (commonly known
as ping), but that's not foolproof. A machine could be up, but unreachable
because of network or routing problems. A machine could be intentionally
not answering pings. A firewall in the way could be filtering out ping
packets. Or, the Echo Request or Echo Reply could have simply gotten lost
somewhere on the network.

What, exactly, are you trying to do?
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      01-15-2006
Harlin Seritt wrote:
> I have a list of IP addresses I am testing with socket.gethostbyaddr().
> For the most part, I am able to get a hostname returned to me when I
> run gethostbyaddr(). I am also hoping this will allow me to tell if a
> computer is up or down. However, in my environment, I am finding that I
> am able to get a hostname even though I am unable to actually ping that
> server (when I ping a server i like this, I get 'request timed out'
> messages telling me that the server is not up).
>
> Other times, I am able to ping a server with success but the
> gethostbyaddr() request will not be able to return a hostname for me
> making me think that machine is truly down when I know it's not. Can
> anyone give me any pointers as to why this happens? Is there anyway I
> can do a reliable ping to another server with Python? I am not
> interested in doing system calls with a system Ping client (I have to
> ping way too many machines and this either takes too long or causes
> severe memory leakage due to MS's horrible ping client). Also, I am
> unable to use Jeremy Hylton's Python ping client because it does little
> more than call gethostbyaddr(). Thanks for taking a look at this.
>

If you have the ability to run code on the machines you are interested
in you might want to consider Nicola Larosa's heartbeat recipe:

http://aspn.activestate.com/ASPN/Coo...n/Recipe/52302

You may also find something useful in

http://pynms.sourceforge.net/ping.html

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57