[nycbug-talk] To ping or not to ping, that is the question...
ike at lesmuug.org
Sat Jul 8 07:11:22 EDT 2006
I'm trying to ping. :)
Ok, so the situation is this- I'm attempting to determine weather or
not a box is 'live', using some kind of external network probe
(ping), hopefully determining if the box is up within 10 seconds or
so- so my program can decide to do other things.
With that, the ping utility was not really designed to accommodate
this need, on several counts:
Inside the box:
- to my knowledge, (and digging through the man pages), ping cannot
bind itself to a particular network interface, which is a problem on
boxes with multiple interfaces, with IP's all on the same subnet.
(ping just finds the first IP route, and pings out on that interface.
Outside the box:
- to my knowledge, (and digging through the man pages), ping does not
have any options which let the utility return some sort of boolean
value for weather or not a packet was returned.
If I'm wrong on either of these points, I'd love for someone to tell
me different- it would get me out of some tedious work here...
(sidenote- I know the implications of my question are a bit heavy,
insomuch as there's *so much* that can happen to make a given ping
fail, network latency, tons of factors... so using ping to determine
weather a box is 'up' is more of an ontological debate than a simple
yes or no answer...)
What I'm planning on doing, to solve my problem(s), is to write a
small utility into my application which creates a network socket on a
specified network interface, and pings from an IP assigned to it-
returning boolean values to my program, so it can decide what to do
(a fail-over type application). This can be done pretty simply in
Python (or similar), I'd just rather use a core system utility and
keep it all in nice portable shell scripts...
Is this a sane idea, or are there some other ping type utilities out
there that people know and love to do the same thing? (Note- I'm not
looking for some kind of Nagios/etc... type solution, I'm looking for
a small stable widget to incorporate into my program).
Any thoughts, urls, chiding, anything- much appreciated...
(Arp related tools would also be a fine solution here, since I'm
really focused on layer 2 [or perhps 3, IP], not services on the
More information about the talk