Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Ping and Tracert

by marcus (Scribe)
on Aug 31, 2001 at 21:47 UTC ( #109458=note: print w/replies, xml ) Need Help??

in reply to Ping and Tracert

Seems to be Net::Ping doesn't suit you, since it'll only return alive/dead, and you can't set the timeout to less than a second.

Shouldn't be too hard to $result=`ping $host`; And parse the output with a simple regexp, but you should be aware that ping returns different output depending on which platform you run it on, so if you are going to distribute it, that might not work for you.

Anyways, good luck :)


Replies are listed 'Best First'.
Re: Re: Ping and Tracert
by qball (Beadle) on Aug 31, 2001 at 21:57 UTC
    It will run on both Solaris and Linux. Any suggestions?


    qball~"I have node idea?!"

      Run ping, generate some output and then I will suggest a regex for you to capture the max. This runs under Win32. The output is after the __DATA__ - you can see the output of ping which puts the regex into perspective.

      $ip = ''; $ping = `ping $ip`; @times = $ping =~ m/time=(\d+)ms/g; @times = sort { $b <=> $a } @times; print "High to low @times ms\n"; print "Highest $times[0] ms\n"; print "Lowest $times[-1] ms\n"; print "This was the repy parsed\n$ping\n"; __DATA__ High to low 414 413 408 403 ms Highest 414 ms Lowest 403 ms This was the repy parsed Pinging [] with 32 bytes of data: Reply from bytes=32 time=408ms TTL=237 Reply from bytes=32 time=413ms TTL=237 Reply from bytes=32 time=414ms TTL=237 Reply from bytes=32 time=403ms TTL=237




        Hey, I'm getting blanks for my times. I'm running the same script, but receiving the following output:
        High to low ms Highest ms Lowest ms


        qball~"I have node idea?!"
      Well, ping on solaris and linux is quite different :/ I don't think solaris supports getting the max value at all other than interactively. I guess an alternative would be compiling GNU perl on the solaris machine, if you aren't going to distribute to a large number of hosts. There is a Net::Ping::External as well, but unfortunately it doesn't give out any more inforation than Net::Ping does.


      Net::Traceroute should do what you need.

      It parses the output of an actual traceroute. I tested it on Linux and it works well. Solaris should work too, the output format is practically the same.

      -- TMTOWTDI

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://109458]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2018-02-20 19:56 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.