Design idea for Ping Application

Marc mnations at airmail.net
Mon Aug 18 19:46:00 EDT 2003


Hi all,

I've been searching old posts for ideas, and can't quite come up with
anything. In short I need an application that will continuously ping
11 different hosts and track the status of the pings. I have the
groundwork laid with 11 objects that can be started or stopped
independently of each other using threads.

However, I'm having trouble working the ping functionality into it.
I've tried using the modules written by various people for pinging,
but haven't been able to make that work. What I have been able to use
is this:

> import os
> p = os.popen("ping X.X.X.X")
> data = p.readlines()
> p.close()

This works, but presents me with a problem. In order to continuously
ping using the "-t" option for ping, I am unable to perform a
readlines() command because it hangs. I've tried other variations of
read commands, but they all hang my system. I guess it keeps looking
for EOF and never finds it because the thing is still running. Is
there a type of read command that just takes what is currently in the
buffer and stores it?

If this doesn't work I can simply do a rotating ping between the 11
hosts as the different threads share time. But this isn't a continuous
flood of traffic like I need. I really need them all running at once.

So how can I get information back from the ping pipe without waiting
for it to finish? I'm also open to other solutions if anyone has come
across something like this before.

Thanks ahead of time,
Marc




More information about the Python-list mailing list