[ltp] OT: how to time a ping command?
Eben King
linux-thinkpad@linux-thinkpad.org
Mon, 20 Sep 2004 11:31:27 -0400 (EDT)
On Mon, 20 Sep 2004, Marius Gedminas wrote:
> On Sun, Sep 19, 2004 at 08:49:51PM -0400, Eben King wrote:
> > On Mon, 20 Sep 2004, André Wyrwa wrote:
> > > Funny, that's exactly what i'm looking for, but my ping.1 doesn't
> > > include this and neither does my ping.
> > > Can you post your --version output please? Mine is from GNU inetutils
> > > 1.4.2 .
>
> Ping in Debian woody does not have a timeout option (-w) either. Ping
> in sarge does.
>
> > I did something much faster (which I can't recall verbatim). It would do
> > something like
> >
> > ping -c 1 somehost > /dev/null &
> > ping_pid=$!
> > { sleep 1 ; kill $ping_pid ; } &
> > sleep_pid=$!
> > wait $ping_pid
> > kill -0 $sleep_pid && # internet connection is up
> > kill $sleep_pid
> >
> > (At least that's how I THINK I did it.) Net effect was that you would
> > only wait for the timeout if the ping wasn't returned. Normally there
> > would just be a ping then life would go on.
>
> Eek.
Well, "ping -c 1 -w 1 somehost" would've replaced most of that.
> I suggest fping. It has sane timeouts (and is present in Debian woody).
>
> Description: sends ICMP ECHO_REQUEST packets to network hosts
> fping is a ping like program which uses the Internet Control Message Protocol
> (ICMP) echo request to determine if a target host is responding. fping
> differs from ping in that you can specify any number of targets on the command
> line, or specify a file containing the lists of targets to ping. Instead of
> sending to one target until it times out or replies, fping will send out a
> ping packet and move on to the next target in a round-robin fashion.
So "fping -c 1 foo bar baz" is roughly equivalent to
for host in foo bar baz ; do
ping -c 1 -w small_number $host
done
?
--
I firmly believed we should not march into Baghdad ...To occupy Iraq would
instantly shatter our coalition, turning the whole Arab world against us and
make a broken tyrant, into a latter-day Arab hero assigning young soldiers
to a fruitless hunt for a securely entrenched dictator [.] - George Bush Sr.