From 73808f2d16a80c350ba420a5d88823e0be509b1b Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 27 Dec 2019 13:53:50 +1000 Subject: Add timeouts tracking. --- apt-panopticommon.lua | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'apt-panopticommon.lua') diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index 71e9a9c..e35201d 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua @@ -491,17 +491,27 @@ APT.plurals = function(e, w, t) return result end +local typs = {'errors', 'warnings', 'timeouts'} APT.padResults = function(results) local c = 0 if nil == results then results = {}; c = 999 end for k, v in pairs(APT.protocols) do tests = results[v] - if nil == tests then tests = {errors = c; warnings = c; timeouts = c} end - if nil == tests.Integrity then tests.Integrity = {errors = c; warnings = c; timeouts = c} end - if nil == tests.Protocol then tests.Protocol = {errors = c; warnings = c; timeouts = c} end - if nil == tests.Updated then tests.Updated = {errors = c; warnings = c; timeouts = c} end - if nil == tests.redirects then tests.redirects = {} end - if nil == tests.URLSanity then tests.URLSanity = {errors = c; warnings = c; timeouts = c} end + if nil == tests then tests = {} end + for m, x in pairs(typs) do + if nil == tests[x] then tests[x] = c end + end + for l, w in pairs(APT.tests) do + if ('raw' ~= w) and ('Speed' ~= w) then + if nil == tests[w] then tests[w] = {} end + for m, x in pairs(typs) do + if nil == tests[w][x] then tests[w][x] = c end + end + end + end + if nil == tests.redirects then + tests.redirects = {} + end results[v] = tests end if nil == results.timeout then results.timeout = false end @@ -589,12 +599,16 @@ local step = '10min' local hb = '150min' local DSIe = 'DS:IntegrityErrors:GAUGE:' .. hb .. ':0:U' local DSIw = 'DS:IntegrityWarnings:GAUGE:' .. hb .. ':0:U' +local DSIt = 'DS:IntegrityTimeouts:GAUGE:' .. hb .. ':0:U' local DSPe = 'DS:ProtocolErrors:GAUGE:' .. hb .. ':0:U' local DSPw = 'DS:ProtocolWarnings:GAUGE:' .. hb .. ':0:U' +local DSPt = 'DS:ProtocolTimeouts:GAUGE:' .. hb .. ':0:U' local DSUe = 'DS:UpdatedErrors:GAUGE:' .. hb .. ':0:U' local DSUw = 'DS:UpdatedWarnings:GAUGE:' .. hb .. ':0:U' +local DSUt = 'DS:UpdatedTimeouts:GAUGE:' .. hb .. ':0:U' local DSSe = 'DS:URLSanityErrors:GAUGE:' .. hb .. ':0:U' local DSSw = 'DS:URLSanityWarnings:GAUGE:' .. hb .. ':0:U' +local DSSt = 'DS:URLSanityTimeouts:GAUGE:' .. hb .. ':0:U' local DSx = 'DS:max:GAUGE:' .. hb .. ':0:U' local DSn = 'DS:min:GAUGE:' .. hb .. ':0:U' -- What Collectd uses. @@ -627,10 +641,10 @@ APT.createRRD = function(host, ip, o) os.execute( 'mkdir -p rrd/' .. host .. '/' .. p:upper()) if not APT.checkFile('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') then D('Creating ' .. 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') - APT.rrd.create( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', '--start', start, '--step', step, DSIe, DSIw, DSPe, DSPw, DSUe, DSUw, DSSe, DSSw, + APT.rrd.create( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', '--start', start, '--step', step, DSIe, DSIw, DSIt, DSPe, DSPw, DSPt, DSUe, DSUw, DSUt, DSSe, DSSw, DSSt, RRAc0, RRAc1, RRAc2, RRAl0, RRAc3, RRAc4, RRAc5, RRAl1, RRAc6, RRAc7, RRAc8, RRAl2, RRAc9, RRAc10, RRAc11, RRAl3, RRAc12, RRAc13, RRAc14, RRAl4) -- Start them at 0 so the average has something to work on. - APT.rrd.update( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', (APT.now - 600) .. ':0:0:0:0:0:0:0:0') + APT.rrd.update( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', (APT.now - 600) .. ':0:0:0:0:0:0:0:0:0:0:0:0') end end os.execute( 'mkdir -p rrd/' .. host .. '/Speed') @@ -647,12 +661,12 @@ APT.updateRRD = function(results, host, ip) for i, p in pairs(APT.protocols) do if nil ~= results[p] then APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':' .. - results[p]['Integrity'].errors .. ':' .. results[p]['Integrity'].warnings .. ':' .. - results[p]['Protocol'].errors .. ':' .. results[p]['Protocol'].warnings .. ':' .. - results[p]['Updated'].errors .. ':' .. results[p]['Updated'].warnings .. ':' .. - results[p]['URLSanity'].errors .. ':' .. results[p]['URLSanity'].warnings) + results[p]['Integrity'].errors .. ':' .. results[p]['Integrity'].warnings .. ':' .. results[p]['Integrity'].timeouts .. ':' .. + results[p]['Protocol'].errors .. ':' .. results[p]['Protocol'].warnings .. ':' .. results[p]['Protocol'].timeouts .. ':' .. + results[p]['Updated'].errors .. ':' .. results[p]['Updated'].warnings .. ':' .. results[p]['Updated'].timeouts .. ':' .. + results[p]['URLSanity'].errors .. ':' .. results[p]['URLSanity'].warnings .. ':' .. results[p]['URLSanity'].timeouts) else - APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':U:U:U:U:U:U:U:U') + APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':U:U:U:U:U:U:U:U:U:U:U:U') end end if nil ~= results.speed then -- cgit v1.1