473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

socket.gethostbyaddr() question

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

Jan 15 '06 #1
2 3169
"Harlin Seritt" <ha**********@yahoo.com> 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?
Jan 15 '06 #2
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/

Jan 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sibylle Koczian | last post by:
Hello all, the documentation for the socket module says that gethostbyaddr should return the primary host name and alternative host names if there are any. But the alias list is empty even in...
3
by: Kathryn Bean | last post by:
I am implementing TCP socket connectivity between several nodes running on Sun platforms. Which function do I need to use to convert from domain name address to IP address in decimal format. ...
1
by: Mohammed Smadi | last post by:
hi; I am trying to do some very basic socket programming and i get the following error. Any help will be appreciated: Code: import socket x = socket.gethostbyaddr("www.google.ca") return...
1
by: JDF | last post by:
I am fairly new to python and seem to have gotten ahead of myself. I am trying to write a Windows service that will return the current number of Citrix sessions to a client. This service will run...
2
by: Neil Aggarwal | last post by:
Hello: I am using gcc on RedHat Linux 9. When I try to do a reverse dns query using gethostbyaddr, it works fine for hosts that have a PTR record, but it returns null for hosts that have a...
1
by: kcw3388 | last post by:
Hi, I have a SunOS TCP/IP client program worked fine for a long time until yesterday. Now, my TCP/IP server program is located on different DNS server. The gethostbyaddr ( ) is now...
2
by: christian9997 | last post by:
Hi Since yesterday about 11.00 CET the gethostbyaddr function doesn't seem to be working. All I get is the IP address back. Is this something general to all PHP users or is this specific to my...
2
by: vasu1308 | last post by:
Hi all I am working on a socket program in Perl. Main goal is to develop a proxy server. Here is the code attached. An error is encountered. Anyone Please help me out. #!/usr/bin/perl -w #...
24
by: RJ_32 | last post by:
When there is no rDNS record on an IP address, then it might take a while for the reverse lookup to timeout. I'm thinking of how on a tracert you can observe the delay. If so, then calling...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.