[Git][NTPsec/ntpsec][master] 7 commits: Tweak titles.

Gary E. Miller gitlab at mg.gitlab.com
Wed Aug 31 19:12:06 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
91b0234d by Gary E. Miller at 2016-08-31T10:38:53-07:00
Tweak titles.

- - - - -
b7d6b273 by Gary E. Miller at 2016-08-31T11:01:43-07:00
Change --local-cpu-temp to --local-temps

Also now reading from them ntpstats/temps file instead of from
ntpstats/cputemp.  Variable and function names changed to match.

- - - - -
b2ae2212 by Gary E. Miller at 2016-08-31T11:36:34-07:00
Plot all the temp sources in the ntpstats/temps file separately.

- - - - -
09871a2d by Gary E. Miller at 2016-08-31T11:50:54-07:00
ALphabetize ntpviz long options.

- - - - -
e09f9380 by Gary E. Miller at 2016-08-31T11:54:16-07:00
Add --local-temps option to man page.

- - - - -
be3f9e4f by Gary E. Miller at 2016-08-31T12:07:52-07:00
Document the temps file format.

- - - - -
43bbfca3 by Gary E. Miller at 2016-08-31T12:11:06-07:00
Alphabetize the log files by filename.

- - - - -


4 changed files:

- docs/includes/ntpviz-body.txt
- docs/statfiles.txt
- ntpstats/ntpviz
- pylib/statfiles.py


Changes:

=====================================
docs/includes/ntpviz-body.txt
=====================================
--- a/docs/includes/ntpviz-body.txt
+++ b/docs/includes/ntpviz-body.txt
@@ -8,11 +8,14 @@
 {ntpviz} [-d statsdir] [-g] [-n name] [-p period]
          [-s starttime] [-e endtime]
          [--local-offset | --local-error | --local-jitter | --local-stability]
+	 [ --all-peer-jitters
+	   | --all-peer-offsets
 	   | --local-offset-histogram
-           | --peer-offsets=hosts | --all-peer-offsets
-           | --peer-jitters=hosts | --all-peer-jitters
-	   | --peer=rtt-host=hostname
-	   | --local-offset-multiplot]
+	   | --local-offset-multiplot
+	   | --local-temps
+           | --peer-jitters=hosts 
+           | --peer-offsets=hosts 
+	   | --peer=rtt-host=hostname]
 	 [-o outdir]
 	 [-D N] [-N]
 
@@ -52,9 +55,15 @@ rendered PNG.
 
 The following plots are available:
 
---local-offset::
-   Clock time and clock frequency offsets from the loop statistics
-   (fields 3 and 4).
+--all-peer-jitters::
+   Report all peer jitters.  This is a different option name from
+   --peer-offsets only because of a limitation in the Python
+   standard library.
+
+--all-peer-offsets::
+   Report all peer offsets.  This is a different option name from
+   --peer-offsets only because of a minor limitation in the Python
+   standard library.
 
 --local-error::
    Clock frequency offset from the loop statistics (field 4)
@@ -62,41 +71,39 @@ The following plots are available:
 --local-jitter::
    Clock time-jitter plot from the loop statistics (field 5).
 
---local-stability::
-   RMS frequency-jitter plot from the loop statistics (field 6).
-   This is deviation from a root-mean-square extrapolation of the
-   moving average of past frequency readings.
+--local-offset::
+   Clock time and clock frequency offsets from the loop statistics
+   (fields 3 and 4).
 
 --local-offset-histogram::
    Frequency histogram of distinct loopstats time offset values (field 3).
 
---peer-offsets=host1[,host2...]::
-   Peer offset from local clock time from peerstats (field 4). A
-   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.
+--local-offset-multiplot::
+   Plot comparative local offsets for multiple directories.
 
---all-peer-offsets::
-   Report all peer offsets.  This is a different option name from
-   --peer-offsets only because of a minor limitation in the Python
-   standard library.
+--local-temps::
+   Plot comparative local temperatures.  This plot is only generated if
+   there is a log file named temps in the log file directory.
+
+--local-stability::
+   RMS frequency-jitter plot from the loop statistics (field 6).
+   This is deviation from a root-mean-square extrapolation of the
+   moving average of past frequency readings.
 
 --peer-jitter=host1[,host2...]::
    Peer jitter from local clock time, from peerstats (field 7)
    A comma-separated list of peer names must follow. It is a fatal
    error for any of these names not to appear in peerstats.
 
---all-peer-jitters::
-   Report all peer jitters.  This is a different option name from
-   --peer-offsets only because of a limitation in the Python
-   standard library.
+--peer-offsets=host1[,host2...]::
+   Peer offset from local clock time from peerstats (field 4). A
+   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.
 
 --peer-rtt=host::
    Show offset plus or minus round-trip-time (rtt) of a specified
    peer. This graph combines fields 4 and 5 of loopstats.
 
---local-offset-multiplot::
-   Plot comparative local offsets for multiple directories.
-
 If no individual plot is specified, all plots and an index HTML page
 are generated into a new output directory.  Normally this directory is
 named 'ntpgraphs', but the name can be changed with the -o option.


=====================================
docs/statfiles.txt
=====================================
--- a/docs/statfiles.txt
+++ b/docs/statfiles.txt
@@ -3,32 +3,30 @@
 The ntpd daemon can produce a variety of statistics files which are
 useful for maintenance, evaluation and retrospective calibration
 purposes. See the ntpd man page for instructions on how to configure
-this feature. There are three file collections presently defined:
-peerstats, loopstats and clockstats, each of which is described in
-this note.
+this feature. There are four file collections presently defined:
+clockstats, loopstats, peerstats and temps, each of which is described
+in this note.
 
 Note: The NTPsec versions of these formats differ in that clock IDs
 consist of a string drivername followed by unit number in parentheses
 rather than the magic IP addresses used in NTP Classic.  The code can
 be built in a Classic compatibility node that restores the old behavior.
 
-== peerstats ==
+The temps file is unique to NTPsec.
 
-The following data are collected in the peerstats files. The files are
-reduced to summary data using the peer.sh shell script. See the peer.awk
-script for further information. A line in the file is produced upon
-reception of each valid update from a configured peer.
+== clockstats ==
+
+A line in this file is produced at each valid update received from a
+refclock configured to append to it. The first part of each data line
+is similar for all radios,
 
 ----------------------------------------------------------------------------
-  49236 30.756 140.173.96.1 9474 0.000603 0.37532
+  49234 60517.826 SPECTRACOM(1) 93 247 16:48:21.814
 
-  49236             modified Julian day number
-  30.756            time of day (s) past midnight UTC
-  140.173.96.1      peer identifier (IP address or receiver identifier)
-  9474              peer status word (hex) (see NTP specification)
-  0.000603          offset (s)
-  0.08929           delay (s)
-  0.37532           dispersion (s)
+  49234                modified Julian day number
+  60517.826            time of day (s) past midnight UTC
+  SPECTRACOM(1)        receiver identifier (Spectracom unit 1)
+  93 247 16:48:21.814  timecode (format varies by refclock)
 ----------------------------------------------------------------------------
 
 == loopstats ==
@@ -50,19 +48,44 @@ valid update of the local clock.
   0                 phase-lock loop time constant
 ----------------------------------------------------------------------------
 
-== clockstats ==
+== peerstats ==
 
-A line in this file is produced at each valid update received from a
-refclock configured to append to it. The first part of each data line
-is similar for all radios, e.g.:
+The following data are collected in the peerstats files. The files are
+reduced to summary data using the peer.sh shell script. See the peer.awk
+script for further information. A line in the file is produced upon
+reception of each valid update from a configured peer.
 
 ----------------------------------------------------------------------------
-  49234 60517.826 SPECTRACOM(1) 93 247 16:48:21.814
+  49236 30.756 140.173.96.1 9474 0.000603 0.37532
 
-  49234                modified Julian day number
-  60517.826            time of day (s) past midnight UTC
-  SPECTRACOM(1)        receiver identifier (Spectracom unit 1)
-  93 247 16:48:21.814  timecode (format varies by refclock)
+  49236             modified Julian day number
+  30.756            time of day (s) past midnight UTC
+  140.173.96.1      peer identifier (IP address or receiver identifier)
+  9474              peer status word (hex) (see NTP specification)
+  0.000603          offset (s)
+  0.08929           delay (s)
+  0.37532           dispersion (s)
+----------------------------------------------------------------------------
+
+== temps ==
+
+This file is user generated.  The wide range of temperature sensors
+makes it too difficult to make it a standard process.  There are
+examples of programs to log data from different temperature sensors in
+the contrib/ directory.
+
+When this file exists, the ntpvi program will graph the data.
+
+Each line in this file is one valid logged temperature.  The file can
+contain data from several different thermometers.  Each line is tagged
+with the data source symbolic name in field 2.
+
+----------------------------------------------------------------------------
+  1471625701 TEMPER 24.9
+
+  1471625701           Unix time, seconds since the start of the epoch
+  TEMPER               Name of the temperature source.
+  24.9                 Meassured temperature in degree Celsius
 ----------------------------------------------------------------------------
 
 //end


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -9,7 +9,7 @@ Usage: ntpviz [-d statsdir] [-g] [-n name] [-p days]
                 | --local-stability | --local-offset-histogram
                 | --peer-offsets=hosts | --all-peer-offsets
                 | --peer-jitters=hosts | --all-peer-jitters
-                | --local-cpu-temp
+                | --local-temps
                 | --local-offset-multiplot]
               [-o outdir]
               [-D N]
@@ -94,23 +94,41 @@ plot \
 """ % locals()
         return plot_template.replace('@', '%') + self.dump("loopstats") + "e\n" + self.dump("loopstats")
 
-    def local_cpu_temp_gnuplot(self):
-        "Generate GNUPLOT code graphing local cpu temp statistics"
+    def local_temps_gnuplot(self):
+        "Generate GNUPLOT code graphing local temperature statistics"
         sitename = self.sitename
-        lines = [line + '\n' for line in getattr(self, "cputemp")]
-        if not len( lines):
-            sys.stderr.write("ntpviz: WARNING: no cputemp to graph\n")
+        tempsmap = self.tempssplit()
+        tempslist = list(tempsmap.keys())
+
+        if not len( tempsmap) or not len( tempslist):
+            sys.stderr.write("ntpviz: WARNING: no temps to graph\n")
             return ''
 
+        temps_data = ()
+        plot_data = ""
+        for key in tempslist:
+            plot_data += "\n".join(tempsmap[key]) + "\ne\n"
+        # remove trailing "e\n"
+        plot_data = plot_data[:-2]
+
+
         plot_template = NTPViz.Common + """\
-set title "%(sitename)s: Local CPU Temp"
+set title "%(sitename)s: Local Temps"
 set ytics format "@1.1f °C" nomirror textcolor rgb '#0060ad'
 set style line 1 lc rgb '#0060ad' lt 1 lw 1 pt 7 ps 0   # --- blue
-plot \
- "-" using 1:3 title "CPU temp" with linespoints ls 1
+plot \\
 """ % locals()
-        return plot_template.replace('@', '%')  \
-            + "".join(lines)
+
+        plot_template = plot_template.replace("@", "%")
+
+        for key in tempslist:
+            plot_template += "'-' using 1:3 title '%(key)s' with line, \\\n" \
+                 % locals()
+
+        # strip the trailing ", \n"
+        plot_template = plot_template[:-4] + "\n"
+        plot_template += plot_data
+        return plot_template
 
     def local_error_gnuplot(self):
         "Plot the local clock frequency error."
@@ -271,14 +289,14 @@ plot \\%(percentages)s
                  % (fld, multiplier, self.ip_label(key))
 
 
-        # strip the trailing ", \\n"
+        # strip the trailing ", \n"
         plot_template = plot_template[:-4] + "\n"
         plot_template += plot_data
         return plot_template
     def peer_offsets_gnuplot(self, peerlist=None):
-        return self.peerstats_gnuplot(peerlist, 4, "Peer clock offset", "offset")
+        return self.peerstats_gnuplot(peerlist, 4, "Peer Clock Offset", "offset")
     def peer_jitters_gnuplot(self, peerlist=None):
-        return self.peerstats_gnuplot(peerlist, 7, "Peer clock jitter", "jitter")
+        return self.peerstats_gnuplot(peerlist, 7, "Peer Clock Jitter", "jitter")
     def peer_rtt_gnuplot(self, host):
         "Plot offset with rtt bounds for specified host."
         sitename = self.sitename
@@ -375,7 +393,7 @@ if __name__ == '__main__':
             "local-offset-histogram",
             "all-peer-offsets", "peer-offsets=",
             "all-peer-jitters", "peer-jitters=",
-            "local-cpu-temp",
+            "local-temps",
             "peer-rtt=",
             "local-offset-multiplot",
             ])
@@ -387,7 +405,7 @@ if __name__ == '__main__':
     period = endtime = starttime = None
     generate = False
     show_local_offset = show_local_error = show_local_jitter = False
-    show_local_stability = show_local_offset_histogram = show_cpu_temp = False
+    show_local_stability = show_local_offset_histogram = show_temps = False
     show_local_offset_multiplot = False
     show_peer_offsets = show_peer_jitters = None
     show_peer_rtt = None
@@ -433,8 +451,8 @@ if __name__ == '__main__':
             show_peer_jitters = []
         elif switch == "--peer-rtt":
             show_peer_rtt = val
-        elif switch == "--local-cpu-temp":
-            show_cpu_temp = True
+        elif switch == "--local-temps":
+            show_temps = True
         elif switch == "--local-offset-multiplot":
             show_local_offset_multiplot = True
     if 0 < debug_level:
@@ -521,12 +539,12 @@ if __name__ == '__main__':
                 sys.stdout.write(plot)
             raise SystemExit(0)
 
-        if show_cpu_temp:
-            if not len( stats.cputemp):
-                sys.stderr.write("ntpviz: ERROR: missing CPU temp data\n")
+        if show_temps:
+            if not len( stats.temps):
+                sys.stderr.write("ntpviz: ERROR: missing temps data\n")
                 raise SystemExit(1)
-            if show_cpu_temp is not None:
-                plot = stats.local_cpu_temp_gnuplot();
+            if show_temps is not None:
+                plot = stats.local_temps_gnuplot();
             if generate:
                 gnuplot(plot)
             else:
@@ -588,9 +606,11 @@ words, how fast it the local clock changes freqency.</p>
 how fast the local clock offset is changing.</p>
 <p>Lower is better.  An ideal system would be a straight line at 0μs.</p>
 """,
-        "local-cpu-temp": """\
-<p>Ambient temperature - changes the clock crystal frequency, it
-oscillates faster when warmer. This the single most important
+        "local-temps": """\
+<p>Local temperatures.  These will be site specific depending on what
+temperature sensors you have and collect data from.  Temperature
+changes change the local clock crystal frequency and stability.  Crystals
+oscillate faster when warmer. This the single most important
 component of frequency drift.</p>
 """,
         "peer-offsets": """\
@@ -741,7 +761,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
                 ("local-jitter", stats.local_offset_jitter_gnuplot()),
                 ("local-stability", stats.local_offset_stability_gnuplot()),
                 ("local-offset-histogram", stats.local_offset_histogram_gnuplot()),
-                ("local-cpu-temp", stats.local_cpu_temp_gnuplot()),
+                ("local-temps", stats.local_temps_gnuplot()),
                 ("peer-offsets", stats.peer_offsets_gnuplot()),
                 ]
             for key in stats.peersplit().keys():


=====================================
pylib/statfiles.py
=====================================
--- a/pylib/statfiles.py
+++ b/pylib/statfiles.py
@@ -59,7 +59,7 @@ class NTPStats:
             raise SystemExit(1)
 
         for stem in ("clockstats", "peerstats", "loopstats", "rawstats", \
-                 "cputemp"):
+                 "temps"):
             lines = []
             try:
                 for logpart in glob.glob(os.path.join(statsdir, stem) + "*"):
@@ -76,8 +76,8 @@ class NTPStats:
                 pass
 
             lines1 = []
-            if stem == "cputemp":
-                # cputemp is already in UNIX time
+            if stem == "temps":
+                # temps is already in UNIX time
                 for line in lines:
                     line = line.strip(' \0\r\n\t')
                     if line != None:
@@ -138,6 +138,15 @@ class NTPStats:
                 peermap[ip] = []
             peermap[ip].append(line)
         return peermap
+    def tempssplit(self):
+        "Return a dictionary mapping temperature sources to entry subsets."
+        tempsmap = {}
+        for line in self.temps:
+            source = line.split()[1]
+            if source not in tempsmap:
+                tempsmap[source] = []
+            tempsmap[source].append(line)
+        return tempsmap
     def dump(self, row):
         "dump a stored list of logfile entries"
         return "\n".join(getattr(self, row)) + "\n"



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6a7a36c0a70026d8cb7f5cd459dc9cd62245def5...43bbfca300abc28ffcf188b520f614a7318991fc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160831/4f2da64b/attachment.html>


More information about the vc mailing list