Files
cacti/scripts/ping.pl
T
Reinhard Scheck b75beb5b9c 0001378: ping.pl script fails when using tcp:hostname
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@4898 860744bd-22fc-0310-8c96-e9fe5004b5ca
2009-01-31 20:01:27 +00:00

19 lines
411 B
Perl

#!/usr/bin/perl
# take care for tcp:hostname or TCP:ip@
$host = $ARGV[0];
$host =~ s/tcp:/$1/gis;
open(PROCESS, "ping -c 1 $host | grep icmp_seq | grep time |");
$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;
}