From ce500339a5445b30effe21e80a4ebe197bd1d89f Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 27 Dec 2019 15:34:14 +1000 Subject: Calculate and display weekly stats. --- apt-panopticon-report-email-web.lua | 48 ++++++++++++++++++++++++++++++++++--- explanations.html | 4 +++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index abc376c..2570c6c 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua @@ -363,7 +363,7 @@ if nil == web then C("opening mirrors file - " .. e) else "\n" .. "" .. "" .. - "\n" + "\n" ) local bg = '' @@ -391,7 +391,7 @@ if nil == web then C("opening mirrors file - " .. e) else local min = tonumber(results.speed.min) local max = tonumber(results.speed.max) local spd = '' - local week = '' + local week = '' local graph = 'graphs' -- DNS-RR test. @@ -432,6 +432,48 @@ if nil == web then C("opening mirrors file - " .. e) else end end + if ("deb.devuan.org" ~= k) then + local percentUp = '???' + local percentUpdated = '???' + if APT.checkFile('rrd/' .. k .. '/Speed/Speed.rrd') then + local start, step, names, data = APT.rrd.fetch('rrd/' .. k .. '/Speed/Speed.rrd', 'LAST', '-a', '-r', '10m', '-s', '-1w') + local count, up, down, unknown = 0, 0, 0, 0 + for i,dp in ipairs(data) do + for j,v in ipairs(dp) do + if 'max' == names[j] then + if 'nan' == tostring(v) then + unknown = unknown + 1 + else + count = count + 1 + if 0 == v then down = down + 1 else up = up + 1 end + end + end + end + end + percentUp = string.format('%d', up / count * 100) + end + if APT.checkFile('rrd/' .. k .. '/HTTP/Tests.rrd') then + local start, step, names, data = APT.rrd.fetch('rrd/' .. k .. '/HTTP/Tests.rrd', 'LAST', '-a', '-r', '10m', '-s', '-1w') + local count, up, down, unknown = 0, 0, 0, 0 + for i,dp in ipairs(data) do + for j,v in ipairs(dp) do + if 'UpdatedErrors' == names[j] then + if 'nan' == tostring(v) then + unknown = unknown + 1 + else + count = count + 1 + if 0 == v then down = down + 1 else up = up + 1 end + end + end + end + end + percentUpdated = string.format('%d', (down / count * 100)) + if '0' == percentUp then percentUpdated = '??' end -- We are counting errors, and you can't get an error if you can't check anything. + -- TODO - try to account for this better, this is just a quick hack. + end + week = '' + end + web:write("\n") @@ -491,7 +533,7 @@ if nil == web then C("opening mirrors file - " .. e) else "
" .. lnk('FTP') .. "" .. lnk('HTTP') .. "" .. lnk('HTTPS') .. "" .. lnk('RSYNC') .. "" .. lnk('DNS round robin', 'DNS-RR') .. "" .. lnk('Protocol') .. "" .. lnk('URL sanity', 'URL-Sanity') .. "" .. lnk('Integrity') .. "" .. lnk('Updated') .. "" .. lnk('Speed range', 'Speed') .. "" .. lnk('Weekly averages', 'Weekly') .. "" .. lnk('Graphs') .. "
" .. lnk('Weekly statistics', 'Weekly') .. "" .. lnk('Graphs') .. "
xxx% upxxx% updated' .. percentUp .. '% up' .. percentUpdated .. '% updated" .. ftp .. " " .. http .. " " .. https .. " " .. rsync .. " " .. dns .. " " .. protocol .. " " .. sanity .. " " .. integrity .. " " .. updated .. " " .. spd .. " " .. week .." " .. graph .. "
\n" .. "" .. "" .. - "\n" + "\n" ) for k, v in APT.orderedPairs(APT.debians) do if '' == bg then bg = " style='background-color:#111111'" else bg = '' end diff --git a/explanations.html b/explanations.html index ae1299a..f4d11fa 100644 --- a/explanations.html +++ b/explanations.html @@ -78,7 +78,9 @@ So take this speed measurement with a grain of salt, it's more of an indication,


Weekly averages

-

This is the percentage of time the mirror was up, and the mirror was up to date.

+

This is the percentage of time the mirror was up, and the percentage of time the mirror was up to date.   +Note that if the mirror has a low uptime, then there wasn't much chance to check if it was up to date. +


Graphs

A link to the graphs for this mirror.

-- cgit v1.1
" .. lnk('FTP') .. "" .. lnk('HTTP') .. "" .. lnk('HTTPS') .. "" .. lnk('RSYNC') .. "" .. lnk('DNS round robin', 'DNS-RR') .. "" .. lnk('Protocol') .. "" .. lnk('URL sanity', 'URL-Sanity') .. "" .. lnk('Integrity') .. "" .. lnk('Updated') .. "" .. lnk('Speed range', 'Speed') .. "" .. lnk('Weekly averages', 'Weekly') .. "" .. lnk('Graphs') .. "
" .. lnk('Weekly statistics', 'Weekly') .. "" .. lnk('Graphs') .. "