[Git][NTPsec/ntpsec][master] 2 commits: ntpviz: remove a magic number.
Gary E. Miller
gitlab at mg.gitlab.com
Tue Oct 11 02:59:35 UTC 2016
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
7ff76967 by Gary E. Miller at 2016-10-10T19:56:41-07:00
ntpviz: remove a magic number.
Real programmers know 86,400 is seconds in a day, but...
- - - - -
18e36889 by Gary E. Miller at 2016-10-10T19:57:52-07:00
ntpviz: Another try at making the X-axis date obvious.
Also, finish writing index.html before outputting summary.csv.
- - - - -
2 changed files:
- ntpstats/ntpviz
- pylib/statfiles.py
Changes:
=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -263,11 +263,11 @@ class NTPViz(NTPStats):
"Class for visualizing statistics from a single server."
# Python takes single quotes here. Since no % substitution
Common = """\
-set terminal png size 900,600
+set terminal png size 900,650
set xdata time
set grid
-set xlabel "Time (dd-hh:mm)"
-set format x "%d-%H:%M"
+set xlabel "Time (DDMM hh:mm UTC)"
+set format x "%d%b %H:%M"
set timefmt "%s"
set xtic rotate by -45 scale 0
set lmargin 12
@@ -1216,7 +1216,8 @@ dd {
end_time = datetime.datetime.fromtimestamp( stats.endtime
).strftime('%c')
- index_header += '<b>Start Time:</b> %s<br><b>End Time:</b> %s<br>\n' \
+ index_header += '<b>Start Time:</b> %s UTC<br>\n' \
+ '<b>End Time:</b> %s UTC<br>\n' \
% (start_time, end_time)
index_header += '<b>Report Period:</b> %1.1f days <br></div>\n' \
% (float(stats.period) / float(NTPStats.SecondsInDay))
@@ -1390,12 +1391,6 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
</div>
"""
- # create csv file
- csv_filename = os.path.join(args.outdir, "summary.csv")
- with open( csv_filename, "w" ) as csv_file:
- csv_file.write(VizStats.csv_head)
- csv_file.write(csvs)
-
# if footer file, add it to index.html
footer = os.path.join(args.outdir, "footer")
if os.path.isfile(footer):
@@ -1410,6 +1405,12 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
# and send the file buffer
with open(os.path.join(args.outdir, "index.html"), "w") as ifile:
ifile.write(index_buffer)
- ifile.close()
+
+ # create csv file
+ csv_filename = os.path.join(args.outdir, "summary.csv")
+ with open( csv_filename, "w" ) as csv_file:
+ csv_file.write(VizStats.csv_head)
+ csv_file.write(csvs)
+
# end
=====================================
pylib/statfiles.py
=====================================
--- a/pylib/statfiles.py
+++ b/pylib/statfiles.py
@@ -12,8 +12,12 @@ import calendar, datetime, glob, gzip, os, socket, subprocess, sys, time
class NTPStats:
"Gather statistics for a specified NTP site"
SecondsInDay = 24*60*60
- DefaultPeriod = 7*24*60*60
+ DefaultPeriod = 7*24*60*60 # default 7 days, 604800 secs
peermap = {} # cached result of peersplit()
+ period = None
+ starttime = None
+ endtime = None
+ sitename = ''
@staticmethod
def unixize(line, starttime, endtime):
@@ -27,8 +31,8 @@ class NTPStats:
except:
# unparseable time 0 and it will be stripped later
return None
- # 86400 = 24 * 60 * 60
- time = 86400*mjd + second - 3506716800 # warning: 32 bit overflows
+ # warning: 32 bit overflows
+ time = NTPStats.SecondsInDay * mjd + second - 3506716800
if time < starttime or time > endtime:
return None
return str(time) + " " + split[2]
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/5fc3aa67f78994d5eeebe85264ff20bf10fa7cd0...18e36889689cefceebb6b4ad06cc2b8ba0522fe4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161011/e1ca0a45/attachment.html>
More information about the vc
mailing list