From 7a8fdb894665b3ce8aec4ef7193a1d13327a76d0 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 13 Nov 2019 20:38:42 +1000 Subject: Clean up the reports, and merge the DNS report into the web report. Include links to the logs. Tweak the colours a little. Put the results into a table, for better readability. --- apt-panopticon-report-web.lua | 90 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 10 deletions(-) (limited to 'apt-panopticon-report-web.lua') diff --git a/apt-panopticon-report-web.lua b/apt-panopticon-report-web.lua index 163d50f..7bb48b0 100755 --- a/apt-panopticon-report-web.lua +++ b/apt-panopticon-report-web.lua @@ -51,6 +51,28 @@ function orderedPairs(t) return orderedNext, t, nil end +-- Use this to dump a table to a string, with HTML. +dumpTableHTML = function (table, space, name) + local r = name .. "\n" + r = r .. dumpTableHTMLSub(table, space .. " ") + r = r .. space .. "" + return r +end +dumpTableHTMLSub = function (table, space) + local r = "" + for k, v in orderedPairs(table) do + if type(v) == "table" then + if " " == space then + r = r .. space .. dumpTableHTML(v, space, k .. "\n" + else + r = r .. "
  • " .. space .. dumpTableHTML(v, space, k .. "
  • \n" + end + else + r = r .. space .. "
  • " .. k .. "
  • \n" + end + end + return r +end local results = {} @@ -114,9 +136,9 @@ local status = function(host, results, typ) if 0 < w then if 0 < e then result = result .. ", " end if 1 == w then - result = result .. w .. " warning" + result = result .. w .. " warning" else - result = result .. w .. " warnings" + result = result .. w .. " warnings" end end if "[OK]" ~= result then @@ -164,15 +186,16 @@ local collate = function(host, ip, results) end local mirrors = loadfile("results/mirrors.lua")() +local m = {} local file, e = io.open("results/Report-web.html", "w+") if nil == file then C("opening mirrors file - " .. e) else file:write( "\n" .. '' .. - "Check date: " .. os.date("!%a %b %d %T %Z %Y") .. "\n
    \n") + "Check date: " .. os.date("!%a %b %d %T %Z %Y") .. "\n
    \n\n") for k, v in orderedPairs(mirrors) do local results = loadfile("results/" .. k .. ".lua")() - file:write(" " .. k .. ".... ") + file:write(" ") local IPs = v.IPs for i, u in pairs(IPs) do if "table" == type(u) then @@ -185,15 +208,62 @@ if nil == file then C("opening mirrors file - " .. e) else end local http = status(k, results, "http") local https = status(k, results, "https") - local dns = "[skip]" + local dns = "[skip]" local protocol = status(k, results, "Protocol") - local sanity = "[skip]" - local integrity = "[skip]" - local updated = "[skip]" - file:write(" http: " .. http .. " https: " .. https .. " DNS-RR: " .. dns .. " Protocol: " .. protocol .. " URL-sanity: " .. sanity .. " Integrity: " .. integrity .. " Updated: " .. updated .. "\n
    \n") + local sanity = "[skip]" + local integrity = "[skip]" + local updated = "[skip]" + file:write("\n") end - file:write( "==== faulty mirrors: ====
    \n
    \n" .. faulty) + file:write( "
    " .. k .. "http: " .. http .. "https: " .. https .. "DNS-RR: " .. + dns .. "Protocol: " .. protocol .. "URL-sanity: " .. sanity .. + "Integrity: " .. integrity .. "Updated: " .. updated .. "
    \n==== faulty mirrors: ====
    \n
    \n" .. faulty) file:write( "\n
    \nLast Failure: NOT WRITTEN YET
    \n
    ") + + for k, v in pairs(mirrors) do + local n = {} + mirrors[k].Protocols = nil + mirrors[k].FQDN = nil + mirrors[k].Active = nil + mirrors[k].Rate = nil + mirrors[k].BaseURL = nil + mirrors[k].Country = nil + mirrors[k].Bandwidth = nil + for l, w in pairs(mirrors[k].IPs) do + if type(w) == "table" then + n[l] = {} + for i, u in pairs(w) do + local nm = "LOG_" .. k .. "_" .. i .. ".html" + local rfile, e = io.open("results/" .. nm, "r") + if nil ~= rfile then + rfile:close() + n[l]["" .. i .. ""] = u + else + n[l][i] = u + end + end + else + local nm = "LOG_" .. k .. "_" .. l .. ".html" + local rfile, e = io.open("results/" .. nm, "r") + if nil ~= rfile then + rfile:close() + n["" .. l .. ""] = w + else + n[l] = w + end + end + end + m[k .. " DNS entries -"] = n + end + file:write("
    \n
    \n
    \n" .. + "

    This DNS report lists each mirror, and the DNS entries for that mirror. " .. + "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. " .. + "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. " .. + "pkgmaster.devuan.org is the master mirror, all the others sync to it. " .. + "The links point to the log files for each FDQN / IP combination that was checked. " .. + "

    \n

    " + ) + file:write(dumpTableHTML(m, "", "")) file:write( "\n
    \n\n\n") file:close() end -- cgit v1.1