[Git][NTPsec/ntpsec][master] Deleted 1 commit: Add --local-cpu-temp option for CPU temp graph.

Gary E. Miller gitlab at mg.gitlab.com
Thu Aug 18 17:39:40 UTC 2016


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


WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.


Deleted commits:
6e6bce0c by Gary E. Miller at 2016-08-18T10:09:48-07:00
Add --local-cpu-temp option for CPU temp graph.

Works in both single graph mode and all graphs mode.
Documentation to follow...

- - - - -


2 changed files:

- ntpstats/ntpstats.py
- ntpstats/ntpviz


Changes:

=====================================
ntpstats/ntpstats.py
=====================================
--- a/ntpstats/ntpstats.py
+++ b/ntpstats/ntpstats.py
@@ -31,7 +31,7 @@ class NTPStats:
     def __init__(self, sitename, statsdir):
         "Grab content of all logfiles, sorted by timestamp."
         self.sitename = sitename
-        for stem in ("clockstats", "peerstats", "loopstats", "rawstats"):
+        for stem in ("clockstats", "peerstats", "loopstats", "rawstats", "cputemp"):
             lines = []
             try:
                 for logpart in glob.glob(os.path.join(statsdir, stem) + "*"):
@@ -46,7 +46,8 @@ class NTPStats:
             # Sort by date
             lines.sort(key=NTPStats.stampfields)
             # Morph first field into Unix time with fractional seconds 
-            lines = [NTPStats.unixize(line) for line in lines]
+            if stem != "cputemp":
+                lines = [NTPStats.unixize(line) for line in lines]
             setattr(self, stem, lines)
     def clip(self, start, end):
         "Select a range of entries"


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# coding: utf-8
 """\
 ntpviz - logfile visualizer for NTP log files
 
@@ -7,6 +8,7 @@ Usage: ntpviz [-d statsdir] [-g] [-n name] [-p days]
               [--local-offset | --local-error | --local-jitter | --local-stability]
               [--peer-offsets=hosts | --all-peer-offsets]
               [--peer-jitters=hosts | --all-peer-jitters]
+              [--local-cpu-temp]
               [-o outdir]
 
 See the manual page for details.
@@ -69,6 +71,20 @@ plot \
  "-" using 1:3 title "frequency offset ppm" with linespoints ls 2 axis x1y2
 """ % 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"
+        sitename = self.sitename
+        plot_template = NTPViz.Common + """\
+set title "%(sitename)s: Local CPU Temp"
+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:($2) title "CPU temp" with linespoints ls 1
+""" % locals()
+        return plot_template.replace('@', '%')  \
+            + "".join(getattr(self, "cputemp"))
+
     def local_error_gnuplot(self):
         "Plot the local clock frequency error."
         sitename = self.sitename
@@ -247,6 +263,7 @@ if __name__ == '__main__':
             "local-offset-histogram",
             "all-peer-offsets", "peer-offsets=",
             "all-peer-jitters", "peer-jitters=",
+            "local-cpu-temp",
             "peer-rtt=",
             ])
     except getopt.GetoptError as err:
@@ -257,7 +274,8 @@ if __name__ == '__main__':
     statsdirs = ["/var/log/ntpstats"]
     endtime = starttime = None
     generate = False
-    show_local_offset = show_local_error = show_local_jitter = show_local_stability = show_local_offset_histogram = False
+    show_local_offset = show_local_error = show_local_jitter = False
+    show_local_stability = show_local_offset_histogram = show_cpu_temp = False
     show_peer_offsets = show_peer_jitters = None
     show_peer_rtt = None
     outdir = "ntpgraphs"
@@ -299,6 +317,8 @@ if __name__ == '__main__':
             show_peer_jitters = []
         elif switch == "--peer-rtt":
             show_peer_rtt = val
+        elif switch == "--local-cpu-temp":
+            show_cpu_temp = True
     period = 24 * 60 * 60 * period_days
     statlist = [NTPViz(statsdir=d, sitename=sitename) for d in statsdirs]
     for stats in statlist:
@@ -365,6 +385,18 @@ if __name__ == '__main__':
                 sys.stdout.write(plot)
             raise SystemExit(0)
 
+        if show_cpu_temp:
+            if not stats.cputemp:
+                sys.stderr.write("ntpviz: missing CPU temp data\n")
+                raise SystemExit(1)
+            if show_cpu_temp is not None:
+                plot = stats.local_cpu_temp_gnuplot();
+            if generate:
+                gnuplot(plot)
+            else:
+                sys.stdout.write(plot)
+            raise SystemExit(0)
+
         # Fall through to HTML code generation
         if not os.path.isdir(outdir):
             try:
@@ -413,6 +445,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
             ("local-stability", stats.local_offset_stability_gnuplot()),
             ("local-offset-histogram", stats.local_offset_histogram_gnuplot()),
             ("peer-offsets", stats.peer_offsets_gnuplot()),
+            ("local-cpu-temp", stats.local_cpu_temp_gnuplot()),
             ]
         for key in stats.peersplit().keys():
             imagepairs.append(("peer-offset-" + key,



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


More information about the vc mailing list