aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon-report-web.lua99
1 files changed, 56 insertions, 43 deletions
diff --git a/apt-panopticon-report-web.lua b/apt-panopticon-report-web.lua
index 5968972..35c61dc 100755
--- a/apt-panopticon-report-web.lua
+++ b/apt-panopticon-report-web.lua
@@ -74,6 +74,25 @@ dumpTableHTMLSub = function (table, space)
74 return r 74 return r
75end 75end
76 76
77local plurals = function(e, w)
78 local result = ""
79 if 1 == e then
80 result = e .. " <font color='red'><b>error</b></font>"
81 elseif e ~= 0 then
82 result = e .. " <font color='red'><b>errors</b></font>"
83 end
84 if 0 < w then
85 if 0 < e then result = result .. ", " end
86 if 1 == w then
87 result = result .. w .. " <font color='yellow'><b>warning</b></font>"
88 else
89 result = result .. w .. " <font color='yellow'><b>warnings</b></font>"
90 end
91 end
92 if "" ~= result then result = " (" .. result .. ")" end
93 return result
94end
95
77local results = {} 96local results = {}
78 97
79local log = function(v, t, s, prot, test, host) 98local log = function(v, t, s, prot, test, host)
@@ -131,27 +150,13 @@ local status = function(host, results, typ)
131 end 150 end
132 end 151 end
133 152
134 if 0 < e then result = e .. " <font color='red'><b>errors</b></font>" end 153 if 0 < e then
135 if 1 == e then result = e .. " <font color='red'><b>error</b></font>" end 154 result = "[<font color='red'><b>FAILED</b></font>]"
136 if 0 < w then 155 faulty = faulty .. host .. " (" .. typ .. ")<br>\n"
137 if 0 < e then result = result .. ", " end 156 else
138 if 1 == w then 157 result = "[<font color='green'><b>OK</b></font>]"
139 result = result .. w .. " <font color='yellow'><b>warning</b></font>"
140 else
141 result = result .. w .. " <font color='yellow'><b>warnings</b></font>"
142 end
143 end
144 if "[OK]" ~= result then
145 if 0 < e then
146 result = "[<font color='red'><b>FAILED</b></font>] (" .. result .. ")"
147 faulty = faulty .. host .. " (" .. typ .. ")<br>\n"
148 elseif 0 < w then
149 result = "[<font color='green'><b>OK</b></font>] (" .. result .. ")"
150 else
151 result = "[<font color='green'><b>OK</b></font>]"
152 end
153 end 158 end
154 return result 159 return result .. plurals(e, w)
155end 160end
156 161
157local collate = function(host, ip, results) 162local collate = function(host, ip, results)
@@ -188,6 +193,31 @@ end
188local mirrors = loadfile("results/mirrors.lua")() 193local mirrors = loadfile("results/mirrors.lua")()
189local m = {} 194local m = {}
190 195
196local logCount = function(domain, ip)
197 local nm = "LOG_" .. domain
198 local log = ""
199 local extra = ""
200 if nil ~= ip then nm = nm .. "_" .. ip end
201 nm = nm .. ".html"
202 local rfile, e = io.open("results/" .. nm, "r")
203 if nil ~= rfile then
204 local errors = 0
205 local warnings = 0
206 for l in rfile:lines() do
207 if nil ~= l:match("><b>ERROR ") then errors = errors + 1 end
208 if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end
209 end
210 rfile:close()
211 if nil == ip then
212 log = "<a href='" .. nm .. "'>" .. domain .. "</a>"
213 else
214 log = "<a href='" .. nm .. "'>" .. ip .. "</a>"
215 end
216 log = log .. plurals(errors, warnings)
217 end
218 return log
219end
220
191local file, e = io.open("results/Report-web.html", "w+") 221local file, e = io.open("results/Report-web.html", "w+")
192if nil == file then C("opening mirrors file - " .. e) else 222if nil == file then C("opening mirrors file - " .. e) else
193 file:write( "<html><head><title>apt-panopticon results</title>\n" .. 223 file:write( "<html><head><title>apt-panopticon results</title>\n" ..
@@ -229,12 +259,7 @@ if nil == file then C("opening mirrors file - " .. e) else
229 for k, v in pairs(mirrors) do 259 for k, v in pairs(mirrors) do
230 local log = k 260 local log = k
231 local n = {} 261 local n = {}
232 local nm = "LOG_" .. k .. ".html" 262 log = logCount(k)
233 local rfile, e = io.open("results/" .. nm, "r")
234 if nil ~= rfile then
235 rfile:close()
236 log = "<a href='" .. nm .. "'>" .. k .. "</a>"
237 end
238 mirrors[k].Protocols = nil 263 mirrors[k].Protocols = nil
239 mirrors[k].FQDN = nil 264 mirrors[k].FQDN = nil
240 mirrors[k].Active = nil 265 mirrors[k].Active = nil
@@ -246,30 +271,18 @@ if nil == file then C("opening mirrors file - " .. e) else
246 if type(w) == "table" then 271 if type(w) == "table" then
247 n[l] = {} 272 n[l] = {}
248 for i, u in pairs(w) do 273 for i, u in pairs(w) do
249 local nm = "LOG_" .. k .. "_" .. i .. ".html" 274 local log = logCount(k, i)
250 local rfile, e = io.open("results/" .. nm, "r") 275 if "" == log then n[l] = u else n[log] = u end
251 if nil ~= rfile then
252 rfile:close()
253 n[l]["<a href='" .. nm .. "'>" .. i .. "</a>"] = u
254 else
255 n[l][i] = u
256 end
257 end 276 end
258 else 277 else
259 local nm = "LOG_" .. k .. "_" .. l .. ".html" 278 local log = logCount(k, l)
260 local rfile, e = io.open("results/" .. nm, "r") 279 if "" == log then n[l] = w else n[log] = w end
261 if nil ~= rfile then
262 rfile:close()
263 n["<a href='" .. nm .. "'>" .. l .. "</a>"] = w
264 else
265 n[l] = w
266 end
267 end 280 end
268 end 281 end
269 m[log .. " DNS entries -"] = n 282 m[log .. " DNS entries -"] = n
270 end 283 end
271 file:write( "<p>This lists each mirror, and the DNS entries for that mirror. " .. 284 file:write( "<p>This lists each mirror, and the DNS entries for that mirror. " ..
272 "The links point to the log files for each FDQN / IP combination that was checked. " .. 285 "The links point to the log files for " .. logCount("apt-panopticon") .. " for each FDQN / IP combination that was checked. " ..
273 "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. " .. 286 "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. " ..
274 "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. " .. 287 "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. " ..
275 "pkgmaster.devuan.org is the master mirror, all the others sync to it. " .. 288 "pkgmaster.devuan.org is the master mirror, all the others sync to it. " ..