[Git][NTPsec/ntpsec][master] 2 commits: ntpviz: remove dead code.
Gary E. Miller
gitlab at mg.gitlab.com
Thu Oct 20 01:42:17 UTC 2016
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
c44d639b by Gary E. Miller at 2016-10-19T16:54:29-07:00
ntpviz: remove dead code.
- - - - -
b0a1d9cb by Gary E. Miller at 2016-10-19T18:39:51-07:00
ntpviz: cut the size of the plot file data again.
Marginal gains here, no measurable speedup, but the on disk plot files
are smaller.
- - - - -
1 changed file:
- ntpstats/ntpviz
Changes:
=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -539,7 +539,7 @@ line at 0ppm. Expected values of 99%-1% percentiles: 0.4ppm</p>
plot_data = ''
for row in self.loopstats:
# Python slice is too dumb to do this the easy way
- # fields: time, fld, and rtt
+ # fields: time, and fld
plot_data += row[0] + ' ' + row[fld - 1] + '\n'
plot_data += "e\n"
@@ -616,10 +616,10 @@ plot \
sys.stderr.write("ntpviz: WARNING: no peer data to graph\n")
return ''
peerlist.sort() # For stability of output
- peer_data = ()
plot_data = ""
namelist = [] # peer names
+ ip_todo = []
for key in peerlist:
# Trickiness - we allow peerlist elements to be DNS names.
# The socket.gethostbyname() call maps DNS names to IP addresses,
@@ -635,14 +635,9 @@ plot \
namelist.append(socket.getfqdn(key))
if ip in peerdict:
- # 20% speed up by only sending gnuplot the data it will
- # actually use
- for row in peerdict[ip]:
- # Python slice is too dumb to do this the easy way
- # fields: time, fld, and rtt
- plot_data += row[0] + ' ' + row[fld - 1] + ' ' + row[4] + '\n'
- plot_data += "e\n"
+ ip_todo.append(ip)
else:
+ # can this ever happen?
sys.stderr.write("ntpviz: ERROR: No such peer as %s" % key)
raise SystemExit(1)
@@ -762,6 +757,20 @@ at 0s.</p>
<p>RMS Jitter is field 8 in the peerstats log file.</p>
"""
+ for ip in ip_todo:
+ # 20% speed up by only sending gnuplot the data it will
+ # actually use
+ # Python slice is too dumb to do this the easy way
+ if rtt:
+ for row in peerdict[ip]:
+ # fields: time, fld, and rtt
+ plot_data += row[0] + ' ' + row[fld-1] + ' ' + row[4] + '\n'
+ else:
+ for row in peerdict[ip]:
+ # fields: time, fld
+ plot_data += row[0] + ' ' + row[fld - 1] + '\n'
+ plot_data += "e\n"
+
out = stats.percs
out['sitename'] = self.sitename
out['title'] = title
@@ -782,10 +791,9 @@ plot \
""" % out
plot_template += percentages
- out['fld'] = 2
for key in peerlist:
out['label'] = self.ip_label(key)
- plot_template += "'-' using 1:($%(fld)s*%(multiplier)s) title '%(label)s' with line, \\\n" \
+ plot_template += "'-' using 1:($2*%(multiplier)s) title '%(label)s' with line, \\\n" \
% out
if 1 == rtt:
@@ -793,6 +801,7 @@ plot \
'-' using 1:(($2+$3/2)*%(multiplier)s) title 'offset+rtt/2' with line, \\
'-' using 1:(($2-$3/2)*%(multiplier)s) title 'offset-rtt/2' with line
""" % stats.percs
+ # sadly, gnuplot needs 3 identical copies of the data.
plot_template += plot_data + plot_data
else:
# strip the trailing ", \n"
@@ -1433,6 +1442,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
if len(statlist) > 1:
index_buffer += local_offset_multiplot(statlist)
else:
+ # imagepairs in the order of the heml entries
imagepairs = [
("local-offset", stats.local_offset_gnuplot()),
# skipa next one, redundant to one above
@@ -1451,12 +1461,12 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
for key in peerlist:
imagepairs.append(("peer-offset-" + key,
stats.peer_offsets_gnuplot([key])))
+
imagepairs.append(("peer-jitters",
stats.peer_jitters_gnuplot()))
for key in peerlist:
- plot = stats.peer_jitters_gnuplot([key])
- if len( plot ):
- imagepairs.append(("peer-jitter-" + key, plot))
+ imagepairs.append(("peer-jitter-" + key,
+ stats.peer_jitters_gnuplot([key])))
stats = []
for (imagename, image) in imagepairs:
@@ -1477,12 +1487,6 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
(imagename.replace(':', '%3A'), div_name)
if image['html']:
index_buffer += "<div>\n%s</div>\n" % image['html']
- if 'peer-jitter-' == imagename[:12]:
- exp = 'peer-jitter'
- elif 'peer-offset-' == imagename[:12]:
- exp = 'peer-offset'
- else:
- exp = imagename
index_buffer += "<br><br>\n"
gnuplot(image['plot'], os.path.join(args.outdir, imagename + ".png"))
index_buffer += "</div>\n"
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/8800be5db75093a08f3882e1b3026615a2b5e66f...b0a1d9cb8975d020ea23246c63214f5b04fcb229
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161020/bd52cab5/attachment.html>
More information about the vc
mailing list