]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Fix ntpsweep to use sntp instead of ntpdate, from Oliver Kindernay
authorHarlan Stenn <stenn@ntp.org>
Fri, 5 Jul 2013 00:43:53 +0000 (20:43 -0400)
committerHarlan Stenn <stenn@ntp.org>
Fri, 5 Jul 2013 00:43:53 +0000 (20:43 -0400)
bk: 51d616c95XGVSQiqGXAkNo6pq6pi_A

ChangeLog
scripts/ntpsweep.in

index 3294e88321da19e5b786996d6a694bd74a3f8383..670046e9f8f9bdb171e97f15850dcd2ad6fe0d19 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* Fix ntpsweep to use sntp instead of ntpdate, from Oliver Kindernay.
 (4.2.7p365) 2013/04/16 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2149] Log an error message if /proc/net/if_inet6 cannot be opened.
 (4.2.7p364) 2013/03/26 Released by Harlan Stenn <stenn@ntp.org>
index e503a0637a346a066c7a0256640e340f9c281339..650d2c5ec08c8b9c101b89ce79fcb46173aa066b 100644 (file)
@@ -26,7 +26,7 @@ my $version = 1.3;
 (my $program = $0) =~ s%.*/(.+?)(.pl)?$%$1%;
 
 # Hardcoded paths/program names
-my $ntpdate = "ntpdate";
+my $sntp = "sntp";
 my $ntpq = "ntpq";
 
 # no STDOUT buffering
@@ -138,18 +138,18 @@ sub scan_host($;$;$) {
     if (&item_in_list($host, @known_hosts)) {
        $known_host = 1;
     } else {
-       # ntpdate part
-       open(NTPDATE, "$ntpdate -bd $host 2>/dev/null |") ||
-       die "Cannot open ntpdate pipe: $!\n";
-       while (<NTPDATE>) {
-           /^stratum\s+(\d+).*$/ && do {
-               $stratum = $1;
-           };
-           /^offset\s+([0-9.-]+)$/ && do {
-               $offset = $1;
-           };
-       }
-       close(NTPDATE);
+       # sntp part
+        open my $sntp_pipe, "$sntp $host 2>/dev/null |" 
+            or die "Cannot open $sntp pipe: $1";
+    
+        while (<$sntp_pipe>) {
+            next if !/^\d{4}-\d\d-\d\d/;
+            my @output = split / /;
+
+            $offset = $output[3];
+            ($stratum = pop @output) =~ s/s(\d{1,2})/$1/;
+        }
+        close $sntp_pipe;
     
        # got answers ? If so, go on.
        if ($stratum) {