Skip to content
Commits on Source (2)
......@@ -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
......@@ -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]
......