[smokeping-users] Re: parsing standard cisco ping

Niko Tyni ntyni+smokeping-users at mappi.helsinki.fi
Fri May 12 19:52:32 MEST 2006


On Sat, May 06, 2006 at 03:49:41AM +0200, Mark wrote:
 
> I need to parse the standard cisco ping output instead of the extended 
> one, below the output:
> 
>     router>ping 192.168.0.1
> 
>     Type escape sequence to abort.
>     Sending 5, 100-byte ICMP Echoes to 192.168.0.1, timeout is 2 seconds:
>     !!!!!
>     Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
> 
>     router>
> 
> The last line is the one I need to parse (success rate, rrt min/avg/max).
> Some one can help me to help to rewrite the parsing function and times 
> functions in TelnetIOS probe?

Hi,

frankly, I don't really understand why you need to do this. The standard
ping is just like the extended ping with the default options, as far as
I know, except that you don't get all the RTT times but just the average
and min/max.

If you really want it, do something like this:

First find the line sending the ping command in TelnetIOSPing.pm:

     $telnet->print("ping");

and change it to something like

     @output = $telnet->cmd("ping $dest");

Then remove everything up to and including

     @output = $telnet->cmd("n");

Then match the times inside 'while (@output)', replacing the line

        $outputline =~ /^Reply to request \d+ \((\d+) ms\)/ && push(@times,$1);

with something like

     if ($outputline =~ /^Success rate is \d+ percent ((\d+)/5), round-trip min/avg/max = (\d+)/(\d+)/(\d+) ms/) {
	my ($number, $min, $avg, $max) = ($1, $2, $3, $4);
	for my $i (1..$number) {
		if ($i == 1) {
			push @times, $min;
		} elsif ($i == $number) {
			push @times, $max;
		} else
			push @times, $avg;
		}
	}
     }

This code puts the average into all the results in between min and max,
which is actually wrong, now that I think of it. I guess you'll have to
replace that with something smarter if you really want to do this.

This is all untested, of course. Hope it helps.

Cheers,
-- 
Niko

--
Unsubscribe mailto:smokeping-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:smokeping-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/smokeping-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the smokeping-users mailing list