#!/usr/bin/perl
#
$host = $ARGV[0];
$count = 10;
$host =~ s/tcp:/$1/gis;
$host =~ s/:[0-9]{1,5}/$1/gis;
#
#
my @data, @timings, @loss;
$pid = open(PROCESS, "/bin/ping -c $count -q $host |");
while (<PROCESS>) {
push (@data, <PROCESS>);
};
close(PROCESS);
@loss = split("received, ", @data[2]);
@loss = split("%", @loss[1]);
if (@loss[0] eq "100.0") {
print "min:U avg:U max:U dev:U loss:100.00";
} else {
@timings = split(" = ", @data[3]);
@timings = split(" ms", @timings[1]);
@timings = split("/", @timings[0]);
# print @data;
print "@timings[1]";
}
Reason: original ping.pl was sending one packet, which casued, that latency measure was innacurate.
Žiadne komentáre:
Zverejnenie komentára