aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticon-report-web.lua
diff options
context:
space:
mode:
authoronefang2019-12-02 06:28:30 +1000
committeronefang2019-12-02 06:28:30 +1000
commit3829c9b7962f11e760361deb764fc96af1345c62 (patch)
tree5d3dde39d99934cc5a21ca7f60f096603d048e19 /apt-panopticon-report-web.lua
parentAdd more report stuff. (diff)
downloadapt-panopticon-3829c9b7962f11e760361deb764fc96af1345c62.zip
apt-panopticon-3829c9b7962f11e760361deb764fc96af1345c62.tar.gz
apt-panopticon-3829c9b7962f11e760361deb764fc96af1345c62.tar.bz2
apt-panopticon-3829c9b7962f11e760361deb764fc96af1345c62.tar.xz
Merge email and web report scripts.
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon-report-email-web.lua (renamed from apt-panopticon-report-web.lua)193
1 files changed, 156 insertions, 37 deletions
diff --git a/apt-panopticon-report-web.lua b/apt-panopticon-report-email-web.lua
index fb41341..60027d0 100755
--- a/apt-panopticon-report-web.lua
+++ b/apt-panopticon-report-email-web.lua
@@ -4,6 +4,7 @@ local args = {...}
4 4
5verbosity = -1 5verbosity = -1
6local logFile 6local logFile
7local html = false
7 8
8 9
9--[[ Ordered table iterator, allow to iterate on the natural order of the keys of a table. 10--[[ Ordered table iterator, allow to iterate on the natural order of the keys of a table.
@@ -77,17 +78,21 @@ end
77local plurals = function(e, w) 78local plurals = function(e, w)
78 local result = "" 79 local result = ""
79 if 1 == e then 80 if 1 == e then
80 result = e .. " <font color='red'><b>error</b></font>" 81 result = e .. " error"
81 elseif e ~= 0 then 82 elseif e ~= 0 then
82 result = e .. " <font color='red'><b>errors</b></font>" 83 result = e .. " errors"
83 end 84 end
85 if ("" ~= result) and html then result = "<font color='red'><b>" .. result .. "</b></font>" end
86-- result = " " .. result
84 if 0 < w then 87 if 0 < w then
85 if 0 < e then result = result .. ", " end 88 if 0 < e then result = result .. ", " end
86 if 1 == w then 89 if 1 == w then
87 result = result .. w .. " <font color='yellow'><b>warning</b></font>" 90 result = result .. w .. " warning"
88 else 91 else
89 result = result .. w .. " <font color='yellow'><b>warnings</b></font>" 92 result = result .. w .. " warnings"
90 end 93 end
94 if ("" ~= result) and html then result = "<font color='yellow'><b>" .. result .. "</b></font>" end
95-- result = " " .. result
91 end 96 end
92 if "" ~= result then result = " (" .. result .. ")" end 97 if "" ~= result then result = " (" .. result .. ")" end
93 return result 98 return result
@@ -127,7 +132,11 @@ local revDNS = function(dom, IP)
127 if "deb.devuan.org" ~= dom then 132 if "deb.devuan.org" ~= dom then
128 if nil ~= mirrors["deb.devuan.org"] then 133 if nil ~= mirrors["deb.devuan.org"] then
129 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][IP] then 134 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][IP] then
130 return "<font color='purple'><b>DNS-RR</b></font>" 135 if html then
136 return "<font color='purple'><b>DNS-RR</b></font>"
137 else
138 return "DNS-RR"
139 end
131 end 140 end
132 end 141 end
133 else 142 else
@@ -184,26 +193,42 @@ local status = function(host, results, typ)
184 end 193 end
185 194
186 if to then 195 if to then
187 if s then 196 result = "[TIMEOUT"
188 result = "[<font color='blue'><b>TIMEOUT</b></font>]" 197 if not s then result = result .. "*" end
189 else 198 if html then
190 result = "[<font color='darkblue'><b>TIMEOUT *</b></font>]" 199 if s then
200 result = "[<font color='blue'><b>TIMEOUT</b></font>"
201 else
202 result = "[<font color='darkblue'><b>TIMEOUT*</b></font>"
203 end
191 end 204 end
192 elseif 0 < e then 205 elseif 0 < e then
193 if s then 206 result = "[FAILED"
194 result = "[<font color='red'><b>FAILED</b></font>]" 207 if not s then result = result .. "*" end
208 if html then
209 if s then
210 result = "[<font color='red'><b>FAILED</b></font>"
211 else
212 result = "[<font color='darkred'><b>FAILED*</b></font>"
213 end
214 end
215 if html then
216 faulty = faulty .. host .. " (" .. typ .. ")<br>\n"
195 else 217 else
196 result = "[<font color='darkred'><b>FAILED *</b></font>]" 218 faulty = faulty .. host .. " (" .. typ .. ")\n"
197 end 219 end
198 faulty = faulty .. host .. " (" .. typ .. ")<br>\n"
199 else 220 else
200 if s then 221 result = "[OK"
201 result = "[<font color='lime'><b>OK</b></font>]" 222 if not s then result = result .. "*" end
202 else 223 if html then
203 result = "[<font color='darkgreen'><b>OK *</b></font>]" 224 if s then
225 result = "[<font color='lime'><b>OK</b></font>"
226 else
227 result = "[<font color='darkgreen'><b>OK*</b></font>"
228 end
204 end 229 end
205 end 230 end
206 return result .. plurals(e, w) 231 return result .. plurals(e, w) .. "]"
207end 232end
208 233
209local collate = function(host, ip, results) 234local collate = function(host, ip, results)
@@ -254,19 +279,113 @@ local logCount = function(domain, ip)
254 if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end 279 if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end
255 end 280 end
256 rfile:close() 281 rfile:close()
257 if nil == ip then 282 if html then
258 log = "<a href='" .. nm .. "'>" .. domain .. "</a>" 283 if nil == ip then
259 else 284 log = "<a href='" .. nm .. "'>" .. domain .. "</a>"
260 log = "<a href='" .. nm .. "'>" .. ip .. "</a>" 285 else
286 log = "<a href='" .. nm .. "'>" .. ip .. "</a>"
287 end
261 end 288 end
262 log = log .. plurals(errors, warnings) 289 log = log .. plurals(errors, warnings)
263 end 290 end
264 return log 291 return log
265end 292end
266 293
267local file, e = io.open("results/Report-web.html", "w+") 294
268if nil == file then C("opening mirrors file - " .. e) else 295html = false
269 file:write( "<html><head><title>apt-panopticon results</title>\n" .. 296local email, e = io.open("results/Report-email.txt", "w+")
297if nil == email then C("opening mirrors file - " .. e) else
298 email:write( "Dear Mirror Admins,\n\n" ..
299 "This is the status of the mirror servers in the Devuan package mirror network.\n\n" ..
300 "The full list of Devuan package mirrors is available at the URL:\n\n" ..
301 " https://pkgmaster.devuan.org/mirror_list.txt\n\n" ..
302 'Please contact "mirrors@devuan.org" if any of the information \nin the file above needs to be amended. \n\n' ..
303 "The full results of the mirror checking is available at the URL:\n\n" ..
304 " https://sledjhamr.org/apt-panopticon/results/Report-web.html\n\n" ..
305 "Due to the nature of the tests, some errors or warnings will be \ncounted several times. " ..
306 "Refer to the logs on the web page for details.\n\n" ..
307 "Please see below the current status of the Devuan Package Mirror \nnetwork:\n\n" ..
308 "==== package mirror status " .. os.date("!%Y-%m-%d %H:%M") .. " GMT ====\n" ..
309 "[skip] means that the test hasn't been written yet.\n\n")
310 for k, v in orderedPairs(mirrors) do
311 local results = loadfile("results/" .. k .. ".lua")()
312 email:write(k .. "....\n")
313 local IPs = v.IPs
314 for i, u in pairs(IPs) do
315 if "table" == type(u) then
316 for h, t in pairs(u) do
317 results = collate(k, h, results)
318 end
319 else
320 results = collate(k, i, results)
321 end
322 end
323 local ftp = "[skip]"
324 local http = status(k, results, "http")
325 local https = status(k, results, "https")
326 local rsync = "[skip]"
327 local dns = ""
328 local protocol = status(k, results, "Protocol")
329 local sanity = "[skip]"
330 local integrity = status(k, results, "Integrity")
331 local updated = status(k, results, "Updated")
332
333 -- DNS-RR test.
334 if ("deb.devuan.org" ~= k) and (nil ~= mirrors["deb.devuan.org"]) then
335 for l, w in pairs(mirrors[k].IPs) do
336 if type(w) == "table" then
337 for i, u in pairs(w) do
338 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][i] then
339 local log = logCount("deb.devuan.org", i)
340 if "" ~= log then
341 if "" == dns then dns = " " else dns = dns .. " " end
342 dns = dns .. logCount("deb.devuan.org", i)
343 else
344 if "" == dns then dns = " " else dns = dns .. " " end
345 dns = dns .. i
346 end
347 end
348 end
349 else
350 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][l] then
351 local log = logCount("deb.devuan.org", l)
352 if "" ~= log then
353 if "" == dns then dns = " " else dns = dns .. " " end
354 dns = dns .. log
355 else
356 if "" == dns then dns = " " else dns = dns .. " " end
357 dns = dns .. l
358 end
359 end
360 end
361 end
362 if "" == dns then dns = "[no]" end
363 dns = " DNS-RR: " .. dns
364 end
365
366 email:write( " ftp: " .. ftp .. " http: " .. http .. " https: " .. https .." rsync: " .. rsync .. "\n" ..
367 " " .. dns .. "\n" ..
368 " Protocol: " .. protocol .. " URL-sanity: " .. sanity .. " Integrity: " .. integrity .. "\n" ..
369 " Updated: " .. updated .. "\n")
370 end
371 email:write( "\n==== faulty mirrors: ====\n" .. faulty)
372 email:write( "\n-------------------------\n\n" ..
373 "* This means that this protocol isn't actually supported, but the test was run ayway.\n\n" ..
374 "Thanks for your precious help in ensuring that Devuan GNU+Linux \nremains a universal, stable, dependable, free operating system.\n\n" ..
375 "You can get the source code from https://sledjhamr.org/cgit/apt-panopticon/about/ .\n\n" ..
376 "Love\n\n" ..
377 "The Dev1Devs\n\n")
378 email:close()
379end
380
381
382results = {}
383m = {}
384faulty = ""
385html = true
386local web, e = io.open("results/Report-web.html", "w+")
387if nil == web then C("opening mirrors file - " .. e) else
388 web:write( "<html><head><title>apt-panopticon results</title>\n" ..
270 '</head><body bgcolor="black" text="white">' .. 389 '</head><body bgcolor="black" text="white">' ..
271 "<h1>Welcome to the apt-panopticon results page.</h1>\n" .. 390 "<h1>Welcome to the apt-panopticon results page.</h1>\n" ..
272 "<p>This is the status of the mirror servers in the Devuan package mirror network.</p>\n" .. 391 "<p>This is the status of the mirror servers in the Devuan package mirror network.</p>\n" ..
@@ -274,11 +393,11 @@ if nil == file then C("opening mirrors file - " .. e) else
274 "<a href='https://pkgmaster.devuan.org/mirror_list.txt'>https://pkgmaster.devuan.org/mirror_list.txt</a></p>\n" .. 393 "<a href='https://pkgmaster.devuan.org/mirror_list.txt'>https://pkgmaster.devuan.org/mirror_list.txt</a></p>\n" ..
275 "<p>Due to the nature of the tests, some errors or warnings will be counted several times. &nbsp; " .. 394 "<p>Due to the nature of the tests, some errors or warnings will be counted several times. &nbsp; " ..
276 "The links in the table and DNS list go to the detailed testing logs.</p>\n\n" .. 395 "The links in the table and DNS list go to the detailed testing logs.</p>\n\n" ..
277 "<hr>\n<h2>==== package mirror status " .. os.date("!%Y-%m-%d %H:%M") .. " GMT: ====</h2>\n<table>\n" .. 396 "<hr>\n<h2>==== package mirror status " .. os.date("!%Y-%m-%d %H:%M") .. " GMT ====</h2>\n<table>\n" ..
278 397
279 "<p>[<font color='red'><b>FAILED</b></font>] or [<font color='lime'><b>OK</b></font>]" .. 398 "<p>[<font color='red'><b>FAILED</b></font>] or [<font color='lime'><b>OK</b></font>]" ..
280 " means the tested thing is supported for that mirror.</p>\n" .. 399 " means the tested thing is supported for that mirror.</p>\n" ..
281 "<p>[<font color='darkred'><b>FAILED *</b></font>] or [<font color='darkgreen'><b>OK *</b></font>]" .. 400 "<p>[<font color='darkred'><b>FAILED*</b></font>] or [<font color='darkgreen'><b>OK*</b></font>]" ..
282 " means the tested thing is unsupported for that mirror, but might have been tested anyway.</p>\n" .. 401 " means the tested thing is unsupported for that mirror, but might have been tested anyway.</p>\n" ..
283 "<p>[<font color='blue'><b>TIMEOUT</b></font>] or [<font color='darkblue'><b>TIMEOUT</b></font>]" .. 402 "<p>[<font color='blue'><b>TIMEOUT</b></font>] or [<font color='darkblue'><b>TIMEOUT</b></font>]" ..
284 " means the server had too many timeouts, and tests where aborted, so there is no result for this test.</p>" .. 403 " means the server had too many timeouts, and tests where aborted, so there is no result for this test.</p>" ..
@@ -294,10 +413,10 @@ if nil == file then C("opening mirrors file - " .. e) else
294 local results = loadfile("results/" .. k .. ".lua")() 413 local results = loadfile("results/" .. k .. ".lua")()
295 local active = "" 414 local active = ""
296 if "yes" == v.Active then 415 if "yes" == v.Active then
297 file:write(" <tr><th>" .. k .. "</th> ") 416 web:write(" <tr><th>" .. k .. "</th> ")
298 else 417 else
299 if nil == v.Active then active = 'nil' else active = v.Active end 418 if nil == v.Active then active = 'nil' else active = v.Active end
300 file:write(" <tr style='background-color:dimgrey'><th>" .. k .. "</th> ") 419 web:write(" <tr style='background-color:dimgrey'><th>" .. k .. "</th> ")
301 end 420 end
302 local IPs = v.IPs 421 local IPs = v.IPs
303 for i, u in pairs(IPs) do 422 for i, u in pairs(IPs) do
@@ -353,15 +472,15 @@ if nil == file then C("opening mirrors file - " .. e) else
353 if "" == dns then dns = "[<font color='grey'><b>no</b></font>]" end 472 if "" == dns then dns = "[<font color='grey'><b>no</b></font>]" end
354 end 473 end
355 474
356 file:write("<td>" .. ftp .. "&nbsp;</td><td>" .. http .. "&nbsp;</td><td>" .. https .. "&nbsp;</td><td>" .. rsync .. "&nbsp;</td><td>" .. dns .. 475 web:write("<td>" .. ftp .. "&nbsp;</td><td>" .. http .. "&nbsp;</td><td>" .. https .. "&nbsp;</td><td>" .. rsync .. "&nbsp;</td><td>" .. dns ..
357 "&nbsp;</td><td>" .. protocol .. "&nbsp;</td><td>" .. sanity .. 476 "&nbsp;</td><td>" .. protocol .. "&nbsp;</td><td>" .. sanity ..
358 "&nbsp;</td><td>" .. integrity .. "&nbsp;</td><td>" .. updated .. "</td></tr>\n") 477 "&nbsp;</td><td>" .. integrity .. "&nbsp;</td><td>" .. updated .. "</td></tr>\n")
359 if "" ~= v.Active then 478 if "" ~= v.Active then
360 file:write("<tr><td style='background-color:dimgrey'>" .. active .. "</td></tr>\n") 479 web:write("<tr><td style='background-color:dimgrey'>" .. active .. "</td></tr>\n")
361 end 480 end
362 end 481 end
363 file:write( "</table>\n<br>\n<h2>==== faulty mirrors: ====</h2>\n" .. faulty) 482 web:write( "</table>\n<br>\n<h2>==== faulty mirrors: ====</h2>\n" .. faulty)
364 file:write( "<br>\n<br>\n<h2>==== DNS and logs: ====</h2>\n") 483 web:write( "<br>\n<br>\n<h2>==== DNS and logs: ====</h2>\n")
365 484
366 for k, v in pairs(mirrors) do 485 for k, v in pairs(mirrors) do
367 local log = k 486 local log = k
@@ -388,7 +507,7 @@ if nil == file then C("opening mirrors file - " .. e) else
388 end 507 end
389 m[log .. " DNS entries -"] = n 508 m[log .. " DNS entries -"] = n
390 end 509 end
391 file:write( "<p>This lists each mirror, and the DNS entries for that mirror. &nbsp; " .. 510 web:write( "<p>This lists each mirror, and the DNS entries for that mirror. &nbsp; " ..
392 "The links point to the testing log files for " .. logCount("apt-panopticon") .. " for each domain name / IP combination that was tested. &nbsp; " .. 511 "The links point to the testing log files for " .. logCount("apt-panopticon") .. " for each domain name / IP combination that was tested. &nbsp; " ..
393 "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. &nbsp; " .. 512 "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. &nbsp; " ..
394 "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. &nbsp; " .. 513 "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. &nbsp; " ..
@@ -396,11 +515,11 @@ if nil == file then C("opening mirrors file - " .. e) else
396 "pkgmaster.devuan.org is the master mirror, all the others sync to it. &nbsp; " .. 515 "pkgmaster.devuan.org is the master mirror, all the others sync to it. &nbsp; " ..
397 "</p>\n" 516 "</p>\n"
398 ) 517 )
399 file:write(dumpTableHTML(m, "", "")) 518 web:write(dumpTableHTML(m, "", ""))
400 file:write( "\n<br>\n<hr>\n\n" .. 519 web:write( "\n<br>\n<hr>\n\n" ..
401 "<p>The <a href='Report-email.txt'>email report</a>. &nbsp; " .. 520 "<p>The <a href='Report-email.txt'>email report</a>. &nbsp; " ..
402 "All <a href='../results'>the logs and other output</a>. &nbsp; " .. 521 "All <a href='../results'>the logs and other output</a>. &nbsp; " ..
403 "You can get the <a href='https://sledjhamr.org/cgit/apt-panopticon/about/'>source code here</a>.</p>" .. 522 "You can get the <a href='https://sledjhamr.org/cgit/apt-panopticon/about/'>source code here</a>.</p>" ..
404 "</body></html>\n") 523 "</body></html>\n")
405 file:close() 524 web:close()
406end 525end