[Git][NTPsec/ntpsec][master] Add 'holdover' refclock flag that can be set in the clock status flag word.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Aug 13 15:17:23 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a0e4ca0c by Eric S. Raymond at 2016-08-13T11:17:12-04:00
Add 'holdover' refclock flag that can be set in the clock status flag word.

- - - - -


6 changed files:

- docs/includes/ntpviz-body.txt
- include/ntp_refclock.h
- ntpd/keyword-gen.c
- ntpd/ntp_config.c
- ntpd/ntp_parser.y
- ntpstats/ntpviz


Changes:

=====================================
docs/includes/ntpviz-body.txt
=====================================
--- a/docs/includes/ntpviz-body.txt
+++ b/docs/includes/ntpviz-body.txt
@@ -8,8 +8,8 @@
 {ntpviz} [-d statsdir] [-g] [-n name] [-p period]
          [-s starttime] [-e endtime]
          [--local-offset | --local-jitter | --local-stability]
-         [--peer-offsets hosts | --all-peer-offsets]
-         [--peer-jitters hosts | --all-peer-jitters]
+         [--peer-offsets=hosts | --all-peer-offsets]
+         [--peer-jitters=hosts | --all-peer-jitters]
 
 == DESCRIPTION ==
 
@@ -24,12 +24,13 @@ The -n option allows you to set the sitename shown in the plot title.
 The default is the basename of the log directory.
 
 The -s, -e and -p options allow you to set the time window to be
-reported on. With -s and -e you set the start and end times as
-ISO8601-style timestamps, - yyyy-mmm-ddThh:mm:ss. Alternatively you
-can specify either -s or -e (but not both) and use -p to set the
-default period in days.  The default is for the period to be 7 days,
-the end time to match the last logfile entry, and the start time to be
-set so that adding the period just reaches the last logfile entry.
+reported on. With -s and -e you set the start and end times as either
+numeric POSIX time or ISO8601-style timestamps, -
+yyyy-mmm-ddThh:mm:ss. Alternatively you can specify either -s or -e
+(but not both) and use -p to set the default period in days.  The
+default is for the period to be 7 days, the end time to match the last
+logfile entry, and the start time to be set so that adding the period
+just reaches the last logfile entry.
 
 The plot options choose what graph is generated; invoke only one.  By
 default, the GNUPLOT for the graph is reported; with -g you get the
@@ -51,8 +52,8 @@ The following plots are available:
 
 --peer-offsets=host1[,host2...]::
    Peer offset from local clock time from peerstats (field 4). A
-   comma-separated list of peer names must follow. It is a fatal
-   error for any of these names not to appear in peerstats.
+   comma-separated list of peer names or IP addresses must follow. It
+   is a fatal error for any of these names not to appear in peerstats.
 
 --all-peer-offsets::
    Report all peer offsets.  This is a different option name from


=====================================
include/ntp_refclock.h
=====================================
--- a/include/ntp_refclock.h
+++ b/include/ntp_refclock.h
@@ -31,6 +31,7 @@
 #define	CLK_FLAG2	0x2
 #define	CLK_FLAG3	0x4
 #define	CLK_FLAG4	0x8
+#define CLK_HOLDOVER	0x10	/* no corresponding HAVE_ flag */
 
 #define	CLK_HAVEFLAG1	0x10
 #define	CLK_HAVEFLAG2	0x20


=====================================
ntpd/keyword-gen.c
=====================================
--- a/ntpd/keyword-gen.c
+++ b/ntpd/keyword-gen.c
@@ -36,6 +36,7 @@ struct key_tok ntp_keywords[] = {
 { "end",		T_End,			FOLLBY_TOKEN },
 { "filegen",		T_Filegen,		FOLLBY_TOKEN },
 { "fudge",		T_Fudge,		FOLLBY_STRING },
+{ "holdover",		T_Holdover,		FOLLBY_TOKEN },
 { "io",			T_Io,			FOLLBY_TOKEN },
 { "includefile",	T_Includefile,		FOLLBY_STRING },
 { "leapfile",		T_Leapfile,		FOLLBY_STRING },


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -834,6 +834,9 @@ create_peer_node(
 				my_node->clock_stat.flags &= ~CLK_FLAG4;
 			break;
 
+		case T_Holdover:
+			my_node->clock_stat.flags |= CLK_HOLDOVER;
+			break;
 #endif /* REFCLOCK */
 
 		default:


=====================================
ntpd/ntp_parser.y
=====================================
--- a/ntpd/ntp_parser.y
+++ b/ntpd/ntp_parser.y
@@ -97,6 +97,7 @@
 %token	<Integer>	T_Floor
 %token	<Integer>	T_Freq
 %token	<Integer>	T_Fudge
+%token	<Integer>	T_Holdover
 %token	<Integer>	T_Host
 %token	<Integer>	T_Huffpuff
 %token	<Integer>	T_Iburst
@@ -458,6 +459,7 @@ option_int_keyword
 	|	T_Subtype
 	|	T_Version
 	|	T_Baud
+	|	T_Holdover
 	;
 
 option_double


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -5,8 +5,8 @@ ntpviz - logfile visualizer for NTP log files
 Usage: ntpviz [-d statsdir] [-g] [-n name] [-p period]
               [-s starttime]  [-e endtime]
               [--local-offset | --local-jitter | --local-stability]
-              [--peer-offsets hosts | --all-peer-offsets]
-              [--peer-jitters hosts | --all-peer-jitters]
+              [--peer-offsets=hosts | --all-peer-offsets]
+              [--peer-jitters=hosts | --all-peer-jitters]
 
 See the manual page for details.
 
@@ -15,7 +15,7 @@ Python by ESR, concept and GNUPLOT code by Dan Drown.
 #SPDX-License-Identifier: BSD-2-Clause
 from __future__ import print_function, division
 
-import os, sys, getopt
+import os, sys, getopt, socket
 from ntpstats import *
 
 # RMS frequency jitter - Deviation from a root-mean-square linear approximation?
@@ -85,9 +85,10 @@ plot \
         return self.loopstats_gnuplot(4, "RMS Time jitter", "Jitter")
     def local_clock_stability_gnuplot(self):
         "Generate GNUPLOT code graphing local clock stability"
-        return self.loopstats_gnuplot(5, "RMS Frequency Jitter - ADEV aka wander", "Stability")
+        return self.loopstats_gnuplot(5, "RMS Frequency Jitter", "Stability")
     def peerstats_gnuplot(self, peerlist, fld, title):
         "Plot a specified field from peerstats."
+        sitename = self.sitename
         peerdict = self.peersplit()
         if not peerlist:
             peerlist = list(peerdict.keys())
@@ -97,20 +98,24 @@ plot \
         else:
             title += "s"
         plot_template = NTPViz.Common + """\
-set title "%s"
+set title "%(sitename)s: %(title)s"
 set ylabel ""
 set ytics format "@1.0f us" nomirror
 set key top right box
 plot \\
-""" % title
+""" % locals()
 	plot_template = plot_template.replace("@", "%")
         for key in peerlist:
             plot_template += "'-' using 1:($%d*1000000) title '%s' with line, \\\n" % (fld, self.ip_label(key))
         
         plot_template = plot_template[:-4] + "\n"
         for key in peerlist:
-            if key in peerdict:
-                plot_template += "\n".join(peerdict[key]) + "\ne\n"
+            # Trickiness - we allow peerlist elements to be DNS names.
+            # The socket.gethostbyname() call maps these to IP addresses,
+            # passing through literal IP addresses unaltered.
+            ip = socket.gethostbyname(key)
+            if ip in peerdict:
+                plot_template += "\n".join(peerdict[ip]) + "\ne\n"
             else:
                 sys.stderr.write("No such peer as %s" % key)
                 raise SystemExit(1)
@@ -121,11 +126,12 @@ plot \\
         return self.peerstats_gnuplot(peerlist, 7, "Peer clock jitter")
     def peer_rtt_gnuplot(self, host):
         "Plot offset with rtt bounds for specified host."
+        sitename = self.sitename
         entries = self.peersplit()[host]
         fifty = self.percentile(4,  50, entries) * 1000000
         host = self.ip_label(host)
         plot_template = NTPViz.Common + """\
-set title "offset of %(host)s"
+set title "%(sitename)s: offset of %(host)s"
 set ylabel ""
 set ytics format "@1.0f us" nomirror
 set key top right box



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a0e4ca0ca54f595f188a91074459db1ca0e3baf4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160813/e52581fa/attachment.html>


More information about the vc mailing list