1#! @PATH_PERL@ 2# 3# drift of 104.8576 -> +1 tick. Base of 10000 ticks. 4# 5# 970306 HMS Deal with nanoseconds. Fix sign of adjustments. 6 7$df="/etc/ntp.drift"; 8# Assumes a 100Hz box with "tick" of 10000 9# Someday, we might call "tickadj" for better values... 10$base=10000; # tick: 1,000,000 / HZ 11$cvt=104.8576; # 2 ** 20 / $base 12$v1=0.; 13$v2=""; 14 15if (open(DF, $df)) 16 { 17 if ($_=<DF>) 18 { 19 ($v1, $v2) = split; 20 } 21 22 while ($v1 < 0) 23 { 24 $v1 += $cvt; 25 $base--; 26 } 27 28 while ($v1 > $cvt) 29 { 30 $v1 -= $cvt; 31 $base++; 32 } 33 } 34 35printf("%.3f (drift)\n", $v1); 36 37printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000); 38 39