Files
cacti/scripts/ping.pl
T
Reinhard Scheck ef45e0880e output "U" in case of failure
re-calculate ping output of usec to print as ms

git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/branches/BRANCH_0_8_6/cacti@4062 860744bd-22fc-0310-8c96-e9fe5004b5ca
2007-08-10 22:13:48 +00:00

14 lines
318 B
Perl

#!/usr/bin/perl
open(PROCESS, "ping -c 1 $ARGV[0] | grep icmp_seq |");
$ping = <PROCESS>;
close(PROCESS);
$ping =~ m/(.*time=)(.*) (ms|usec)/;
if ($2 == "") {
print "U"; # avoid cacti errors, but do not fake rrdtool stats
}elsif ($3 eq "usec") {
print $2/1000; # re-calculate in units of "ms"
}else{
print $2;
}