[ntp:bk-ntp-dev-send] BitKeeper diffs

stenn at whimsy.udel.edu stenn at whimsy.udel.edu
Fri Jul 5 01:18:07 UTC 2013


#### ChangeSet ####
2013-07-04 20:43:53-04:00, stenn at psp-deb1.ntp.org
  Fix ntpsweep to use sntp instead of ntpdate, from Oliver Kindernay

==== ChangeLog ====
2013-07-04 20:43:29-04:00, stenn at psp-deb1.ntp.org +1 -0
  Fix ntpsweep to use sntp instead of ntpdate, from Oliver Kindernay

--- 1.1289/ChangeLog	2013-04-16 05:54:57 -04:00
+++ 1.1289.1.1/ChangeLog	2013-07-04 20:43:29 -04:00
@@ -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 at 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 at ntp.org>

==== scripts/ntpsweep.in ====
2013-07-04 20:43:30-04:00, stenn at psp-deb1.ntp.org +13 -13
  Fix ntpsweep to use sntp instead of ntpdate, from Oliver Kindernay

--- 1.3/scripts/ntpsweep.in	2007-03-03 19:21:17 -05:00
+++ 1.4/scripts/ntpsweep.in	2013-07-04 20:43:30 -04:00
@@ -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) {


More information about the bk-ntp-dev-send mailing list