From 41bf384e6fd80e983a6061801ca9d56a2bb696f5 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 10 Dec 2019 18:58:47 +1000 Subject: Pad out the results tables when loading them. --- apt-panopticommon.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index b38595c..65a50b8 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua @@ -397,12 +397,27 @@ APT.plurals = function(e, w) return result end +APT.fill = function(results) + for k, v in pairs{"ftp", "http", "https", "rsync"} do + tests = results[v] + if nil == tests then tests = {errors = 0; warnings = 0} end + if nil == tests.Integrity then tests.Integrity = {errors = 0; warnings = 0} end + if nil == tests.Protocol then tests.Protocol = {errors = 0; warnings = 0} end + if nil == tests.Updated then tests.Updated = {errors = 0; warnings = 0} end + if nil == tests.URLSanity then tests.URLSanity = {errors = 0; warnings = 0} end + results[v] = tests + end + return results +end + APT.collate = function(host, ip, results) + results = APT.fill(results) local f = "results/" .. host .. "_" .. ip .. ".lua" local rfile, e = io.open(f, "r") if nil == rfile then I("opening " .. f .. " file - " .. e) else rfile:close() local rs = loadfile(f)() + rs = APT.fill(rs) for k, v in pairs(rs) do if "table" == type(v) then if ("speed" == k) and (nil ~= results.speed) then @@ -538,6 +553,7 @@ end APT.doRRD = function(l, k, v) if APT.checkFile(l .. "/" .. k .. ".lua") then local results = loadfile(l .. "/" .. k .. ".lua")() + results = APT.fill(results) APT.createRRD(k) APT.updateRRD(results, k) if til ~= v then -- cgit v1.1