]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 512] Reintroduce -m to ntptrace. From Frederic Planchon
authorHarlan Stenn <stenn@ntp.org>
Sat, 22 Oct 2005 03:23:52 +0000 (23:23 -0400)
committerHarlan Stenn <stenn@ntp.org>
Sat, 22 Oct 2005 03:23:52 +0000 (23:23 -0400)
bk: 4359b0c8rXiE_rGAC4eTg9mOjwN4bg

scripts/ntptrace.in

index 0cea742a09183d087879eacbdc10de4b392df5f0..c3c2a20fda3524b55952e19cb32c36df5351977d 100755 (executable)
@@ -4,19 +4,24 @@
 
 use Socket;
 use Getopt::Std;
-use vars qw($opt_n);
+use vars qw($opt_n $opt_m);
 
 $ntpq = "ntpq";
 
-getopts('n');
+getopts('nm:');
 
 $dodns = 1;
 $dodns = 0 if (defined($opt_n));
 
+$max_hosts = (defined($opt_m) ? $opt_m :  99);
+$max_hosts = 0 if ( $max_hosts !~ /^\d+$/ );
+$nb_host = 1;
+
 $host = shift;
 $host ||= "127.0.0.1";
 
 for (;;) {
+       $nb_host++;
        $rootdelay = 0;
        $rootdispersion = 0;
        $stratum = 255;
@@ -49,6 +54,7 @@ for (;;) {
        printf("\n");
        last if ($stratum == 0 || $stratum == 1 || $stratum == 16);
        last if ($refid =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
+       last if ($nb_host > $max_hosts);
 
        $cmd = "$ntpq -n -c \"pstat $peer\" $host";
        open(PH, $cmd . "|") || die "failed to start command $cmd: $!";