[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fixed pingit script



Rather than checking that the last line contains aroot.psg.com, it now checks that the last line ends in "digit" ms.
Please tst.

          Harald

#!/usr/bin/perl
# Ping the aroot nameserver, finding out where it is
$date = `date +%Y-%m-%dT%H:%M`;
chop $date;
$tracert = `/usr/sbin/traceroute -f 9 aroot.psg.com 2>/dev/null | tail -2`;
($prev, $last) = split(/\n/, $tracert);
($hopc, $hostp, $ip, $delay) = split(/\s+/, $prev);
($hopc, $host, $ip, $delay) = split(/\s+/, $last);
if ($last =~ /\d ms$/) {
    print "$date SUCCESS $hopc $delay $hostp/$host\n";
} else {
    # For debug of FAILURE algo:
    print "# $prev\n";
    print "# $last\n";
    print "$date FAILURE $hopc $delay $host\n";
}