]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL.
authorHarlan Stenn <stenn@ntp.org>
Sat, 21 Feb 2015 09:51:32 +0000 (09:51 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 21 Feb 2015 09:51:32 +0000 (09:51 +0000)
bk: 54e85524b_MqbtcZiMbWdGg_4Mft8w

ChangeLog
scripts/lib/NTP/Util.pm

index 60173cc7c3ddda89a2cdc1b9405ac1b807d25c79..99784228bf945f406877c084b63d9b9566b4eed0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 * [Bug 2728] See if C99-style structure initialization works.
 * [Bug 2747] Upgrade libevent to 2.1.5-beta.
+* [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL. .
 ---
 (4.2.8p1) 2015/02/04 Released by Harlan Stenn <stenn@ntp.org>
 
index 66f2453bf0cfd9a80c4a9edb194db68f38dbedc3..cd2f9e5a7a5d524a2bc6726c0e43a5a571f9304e 100644 (file)
@@ -93,18 +93,27 @@ sub do_dns {
 sub ntp_peers {
     my ($host) = @_;
 
-    my $cmd = "$ntpq_path -np $host |";
+    $host ||= '';
+    my $cmd = "$ntpq_path -npw $host |";
 
     open my $fh, $cmd or croak "Could not start ntpq: $!";
 
     <$fh> for 1 .. 2;
 
-    my @columns = qw(remote refid st t when poll reach delay offset jitter);
+    my @columns = qw(tally host refid st t when poll reach delay offset jitter);
     my @peers;
     while (<$fh>) {
-        if (/(?:[\w\.\*-]+\s*){10}/) {
+        if (/^([ x+#*o-])((?:[\w.*:-]+\s+){10}|([\w.*:-]+\s+))$/) {
             my $col = 0;
-            push @peers, { map {; $columns[ $col++ ] => $_ } split /(?<=.)\s+/ };
+           my @line = ($1, split /\s+/, $2);
+           if( @line == 2 ) {
+               defined ($_ = <$fh>) or last;
+               s/^\s+//;
+               push @line, split /\s+/;
+           }
+           my $r = { map {; $columns[ $col++ ] => $_ } @line };
+           $r->{remote} = $r->{tally} . $r->{host};
+            push @peers, $r;
         }
         else {
             #TODO return error (but not needed anywhere now)
@@ -135,3 +144,5 @@ sub ntp_sntp_line {
     close $fh or croak "running sntp failed: $! (exit status $?)";
     return ($offset, $stratum);
 }
+
+1;