[Git][NTPsec/ntpsec][master] Factor out common GNUPLOT code.
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Aug 11 19:11:00 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
8110c24f by Eric S. Raymond at 2016-08-11T15:10:28-04:00
Factor out common GNUPLOT code.
- - - - -
2 changed files:
- ntpstats/ntpstats.py
- ntpstats/ntpviz
Changes:
=====================================
ntpstats/ntpstats.py
=====================================
--- a/ntpstats/ntpstats.py
+++ b/ntpstats/ntpstats.py
@@ -4,11 +4,7 @@ ntpstats.py - class for digesting and plotting NTP logfiles
Requires GNUPLOT and liberation fonts installed.
SPDX-License-Identifier: BSD-2-Clause
-
-Python by ESR, concept and GNUPLOT code by Dan Drown.
"""
-# RMS frequency jitter - Deviation from a root-mean-square linear approximation?
-# Investigate.
from __future__ import print_function, division
import os, sys, time, glob, calendar, subprocess, socket
=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -9,6 +9,8 @@ Usage: ntpviz [-d statsdir] [-g] [-n name] [-p period]
[--peer-jitters hosts | --all-peer-jitters]
See the manual page for details.
+
+Python by ESR, concept and GNUPLOT code by Dan Drown.
"""
#SPDX-License-Identifier: BSD-2-Clause
from __future__ import print_function, division
@@ -16,29 +18,34 @@ from __future__ import print_function, division
import os, sys, getopt
from ntpstats import *
+# RMS frequency jitter - Deviation from a root-mean-square linear approximation?
+# Investigate.
+
class NTPViz(NTPStats):
"Class for visualizing statistics from a sincle server."
- def __init__(self, sitename, statsdir):
- NTPStats.__init__(self, sitename, statsdir)
- def local_clock_gnuplot(self):
- "Generate GNUPLOT code graphing local clock loop statistics"
- sitename = self.sitename
- plot_template = """\
-set title "%(sitename)s: Local Clock Offsets"
+ Common = """\
set terminal png size 900,600
set xdata time
-set timefmt "@s"
set grid
set xlabel "Time"
set format x "@d- at H:@M"
+set timefmt "@s"
set xtic rotate by -45 scale 0
+set lmargin 12
+set rmargin 12
+"""
+ def __init__(self, sitename, statsdir):
+ NTPStats.__init__(self, sitename, statsdir)
+ def local_clock_gnuplot(self):
+ "Generate GNUPLOT code graphing local clock loop statistics"
+ sitename = self.sitename
+ plot_template = NTPViz.Common + """\
+set title "%(sitename)s: Local Clock Offsets"
set ytics format "@1.2f us" nomirror textcolor rgb '#0060ad'
set y2tics format "@2.3f ppm" nomirror textcolor rgb '#dd181f'
set key bottom right box
set style line 1 lc rgb '#0060ad' lt 1 lw 1 pt 7 ps 0 # --- blue
set style line 2 lc rgb '#dd181f' lt 1 lw 1 pt 5 ps 0 # --- red
-set lmargin 12
-set rmargin 12
plot \
"-" using 1:($2*1000000) title "clock offset us" with linespoints ls 1, \
"-" using 1:3 title "frequency offset ppm" with linespoints ls 2 axis x1y2
@@ -53,15 +60,8 @@ plot \
one = self.percentile(fld, 1, self.loopstats) * 1000000
nf_m_f = ninetyfive - five
nn_m_o = ninetynine - one
- plot_template = """\
+ plot_template = NTPViz.Common + """\
set title "%(sitename)s: %(title)s"
-set terminal png size 900,600
-set xdata time
-set timefmt "@s"
-set grid
-set xlabel "Time"
-set format x "@d- at H:@M"
-set xtic rotate by -45 scale 0
set ytics format "@1.2f us" nomirror
set key top right box
set style line 1 lc rgb '#0060ad' lt 1 lw 1 pt 7 ps 0 # --- blue
@@ -72,8 +72,6 @@ set label 3 gprintf(" 5@@ = %(five)s us",5) at graph 0.01,0.85 left front
set label 4 gprintf(" 1@@ = %(one)s us",1) at graph 0.01,0.8 left front
set label 5 gprintf("95@@ - 5@@ = %(nf_m_f)s us",90) at graph 0.01,0.75 left front
set label 6 gprintf("99@@ - 1@@ = %(nn_m_o) us",98) at graph 0.01,0.7 left front
-set lmargin 12
-set rmargin 12
plot \
"-" using 1:($%(fld)d*1000000) title "%(legend)s" with linespoints ls 1, \
%(ninetynine)s title "99th percentile", \
@@ -98,20 +96,11 @@ plot \
title += ": "+ peerlist[0]
else:
title += "s"
- plot_template = """\
+ plot_template = NTPViz.Common + """\
set title "%s"
-set terminal png size 900,600
-set xdata time
-set timefmt "@s"
-set grid
-set xlabel "Time"
-set format x "@d- at H:@M"
-set xtic rotate by -45 scale 0
set ylabel ""
set ytics format "@1.0f us" nomirror
set key top right box
-set lmargin 12
-set rmargin 12
plot \\
""" % title
plot_template = plot_template.replace("@", "%")
@@ -135,20 +124,11 @@ plot \\
entries = self.peersplit()[host]
fifty = self.percentile(4, 50, entries) * 1000000
host = self.ip_label(host)
- plot_template = """\
+ plot_template = NTPViz.Common + """\
set title "offset of %(host)s"
-set terminal png size 900,600
-set xdata time
-set timefmt "@s"
-set grid
-set xlabel "Time"
-set format x "@d- at H:@M"
-set xtic rotate by -45 scale 0
set ylabel ""
set ytics format "@1.0f us" nomirror
set key top right box
-set lmargin 12
-set rmargin 12
plot \
'-' using 1:($4*1000000) title 'offset' with line, \
'-' using 1:(($4+$5/2)*1000000) title 'offset+rtt/2' with line, \
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8110c24f515d33197fae6b914dcedfa29adc2bca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160811/cc5a9c94/attachment.html>
More information about the vc
mailing list