]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 217] ntptrace should show sync distance, not rootdelay.
authorHarlan Stenn <stenn@ntp.org>
Thu, 20 Nov 2003 08:44:29 +0000 (03:44 -0500)
committerHarlan Stenn <stenn@ntp.org>
Thu, 20 Nov 2003 08:44:29 +0000 (03:44 -0500)
bk: 3fbc7eedbLEDslQch_lnrczpNuvS0A

scripts/ntptrace.in

index 07d2ddc308b8d3277e1322c530b78fc4678d20db..c58a84abef6b5e296dbee4173e45e181298d15ad 100755 (executable)
@@ -17,6 +17,8 @@ $host = shift;
 $host ||= "127.0.0.1";
 
 for (;;) {
+       $rootdelay = 0;
+       $rootdispersion = 0;
        $stratum = 255;
        $cmd = "$ntpq -n -c rv $host";
        open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
@@ -26,12 +28,13 @@ for (;;) {
                # Very old servers report phase and not offset.
                $offset = $1 if (/(?:offset|phase)=([^\s,]+)/);
                $rootdelay = $1 if (/rootdelay=([^\s,]+)/);
+               $rootdispersion = $1 if (/rootdispersion=(^\s,]+)/);
                $refid = $1 if (/refid=([^\s,]+)/);
        }
        close(PH) || die "$cmd failed";
        last if ($stratum == 255);
        $offset /= 1000;
-       $rootdelay /= 1000;
+       $syncdistance = ($rootdispersion + ($rootdelay / 2)) / 1000;
        $dhost = $host;
        # Only do lookups of IPv4 addresses. The standard lookup functions
        # of perl only do IPv4 and I don't know if we should require extras.
@@ -40,8 +43,8 @@ for (;;) {
                $name = (gethostbyaddr($iaddr, AF_INET))[0];
                $dhost = $name if (defined($name));
        }
-       printf("%s: stratum %d, offset %f, root distance %f",
-           $dhost, $stratum, $offset, $rootdelay);
+       printf("%s: stratum %d, offset %f, synch distance %f",
+           $dhost, $stratum, $offset, $syncdistance);
        printf(", refid '%s'", $refid) if ($stratum == 1);
        printf("\n");
        last if ($stratum == 0 || $stratum == 1 || $stratum == 16);