diff options
author | onefang | 2019-12-27 13:53:50 +1000 |
---|---|---|
committer | onefang | 2019-12-27 13:53:50 +1000 |
commit | 73808f2d16a80c350ba420a5d88823e0be509b1b (patch) | |
tree | 783e36eac4fbaf9ef2be36a68ae2b6efa64695bf | |
parent | Optimise updater a tiny bit. (diff) | |
download | apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.zip apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.gz apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.bz2 apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.xz |
Add timeouts tracking.
-rw-r--r-- | apt-panopticommon.lua | 40 | ||||
-rwxr-xr-x | apt-panopticon-update-data.lua | 34 |
2 files changed, 60 insertions, 14 deletions
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) | |||
491 | return result | 491 | return result |
492 | end | 492 | end |
493 | 493 | ||
494 | local typs = {'errors', 'warnings', 'timeouts'} | ||
494 | APT.padResults = function(results) | 495 | APT.padResults = function(results) |
495 | local c = 0 | 496 | local c = 0 |
496 | if nil == results then results = {}; c = 999 end | 497 | if nil == results then results = {}; c = 999 end |
497 | for k, v in pairs(APT.protocols) do | 498 | for k, v in pairs(APT.protocols) do |
498 | tests = results[v] | 499 | tests = results[v] |
499 | if nil == tests then tests = {errors = c; warnings = c; timeouts = c} end | 500 | if nil == tests then tests = {} end |
500 | if nil == tests.Integrity then tests.Integrity = {errors = c; warnings = c; timeouts = c} end | 501 | for m, x in pairs(typs) do |
501 | if nil == tests.Protocol then tests.Protocol = {errors = c; warnings = c; timeouts = c} end | 502 | if nil == tests[x] then tests[x] = c end |
502 | if nil == tests.Updated then tests.Updated = {errors = c; warnings = c; timeouts = c} end | 503 | end |
503 | if nil == tests.redirects then tests.redirects = {} end | 504 | for l, w in pairs(APT.tests) do |
504 | if nil == tests.URLSanity then tests.URLSanity = {errors = c; warnings = c; timeouts = c} end | 505 | if ('raw' ~= w) and ('Speed' ~= w) then |
506 | if nil == tests[w] then tests[w] = {} end | ||
507 | for m, x in pairs(typs) do | ||
508 | if nil == tests[w][x] then tests[w][x] = c end | ||
509 | end | ||
510 | end | ||
511 | end | ||
512 | if nil == tests.redirects then | ||
513 | tests.redirects = {} | ||
514 | end | ||
505 | results[v] = tests | 515 | results[v] = tests |
506 | end | 516 | end |
507 | if nil == results.timeout then results.timeout = false end | 517 | if nil == results.timeout then results.timeout = false end |
@@ -589,12 +599,16 @@ local step = '10min' | |||
589 | local hb = '150min' | 599 | local hb = '150min' |
590 | local DSIe = 'DS:IntegrityErrors:GAUGE:' .. hb .. ':0:U' | 600 | local DSIe = 'DS:IntegrityErrors:GAUGE:' .. hb .. ':0:U' |
591 | local DSIw = 'DS:IntegrityWarnings:GAUGE:' .. hb .. ':0:U' | 601 | local DSIw = 'DS:IntegrityWarnings:GAUGE:' .. hb .. ':0:U' |
602 | local DSIt = 'DS:IntegrityTimeouts:GAUGE:' .. hb .. ':0:U' | ||
592 | local DSPe = 'DS:ProtocolErrors:GAUGE:' .. hb .. ':0:U' | 603 | local DSPe = 'DS:ProtocolErrors:GAUGE:' .. hb .. ':0:U' |
593 | local DSPw = 'DS:ProtocolWarnings:GAUGE:' .. hb .. ':0:U' | 604 | local DSPw = 'DS:ProtocolWarnings:GAUGE:' .. hb .. ':0:U' |
605 | local DSPt = 'DS:ProtocolTimeouts:GAUGE:' .. hb .. ':0:U' | ||
594 | local DSUe = 'DS:UpdatedErrors:GAUGE:' .. hb .. ':0:U' | 606 | local DSUe = 'DS:UpdatedErrors:GAUGE:' .. hb .. ':0:U' |
595 | local DSUw = 'DS:UpdatedWarnings:GAUGE:' .. hb .. ':0:U' | 607 | local DSUw = 'DS:UpdatedWarnings:GAUGE:' .. hb .. ':0:U' |
608 | local DSUt = 'DS:UpdatedTimeouts:GAUGE:' .. hb .. ':0:U' | ||
596 | local DSSe = 'DS:URLSanityErrors:GAUGE:' .. hb .. ':0:U' | 609 | local DSSe = 'DS:URLSanityErrors:GAUGE:' .. hb .. ':0:U' |
597 | local DSSw = 'DS:URLSanityWarnings:GAUGE:' .. hb .. ':0:U' | 610 | local DSSw = 'DS:URLSanityWarnings:GAUGE:' .. hb .. ':0:U' |
611 | local DSSt = 'DS:URLSanityTimeouts:GAUGE:' .. hb .. ':0:U' | ||
598 | local DSx = 'DS:max:GAUGE:' .. hb .. ':0:U' | 612 | local DSx = 'DS:max:GAUGE:' .. hb .. ':0:U' |
599 | local DSn = 'DS:min:GAUGE:' .. hb .. ':0:U' | 613 | local DSn = 'DS:min:GAUGE:' .. hb .. ':0:U' |
600 | -- What Collectd uses. | 614 | -- What Collectd uses. |
@@ -627,10 +641,10 @@ APT.createRRD = function(host, ip, o) | |||
627 | os.execute( 'mkdir -p rrd/' .. host .. '/' .. p:upper()) | 641 | os.execute( 'mkdir -p rrd/' .. host .. '/' .. p:upper()) |
628 | if not APT.checkFile('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') then | 642 | if not APT.checkFile('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') then |
629 | D('Creating ' .. 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') | 643 | D('Creating ' .. 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd') |
630 | APT.rrd.create( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', '--start', start, '--step', step, DSIe, DSIw, DSPe, DSPw, DSUe, DSUw, DSSe, DSSw, | 644 | 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, |
631 | RRAc0, RRAc1, RRAc2, RRAl0, RRAc3, RRAc4, RRAc5, RRAl1, RRAc6, RRAc7, RRAc8, RRAl2, RRAc9, RRAc10, RRAc11, RRAl3, RRAc12, RRAc13, RRAc14, RRAl4) | 645 | RRAc0, RRAc1, RRAc2, RRAl0, RRAc3, RRAc4, RRAc5, RRAl1, RRAc6, RRAc7, RRAc8, RRAl2, RRAc9, RRAc10, RRAc11, RRAl3, RRAc12, RRAc13, RRAc14, RRAl4) |
632 | -- Start them at 0 so the average has something to work on. | 646 | -- Start them at 0 so the average has something to work on. |
633 | APT.rrd.update( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', (APT.now - 600) .. ':0:0:0:0:0:0:0:0') | 647 | APT.rrd.update( 'rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', (APT.now - 600) .. ':0:0:0:0:0:0:0:0:0:0:0:0') |
634 | end | 648 | end |
635 | end | 649 | end |
636 | os.execute( 'mkdir -p rrd/' .. host .. '/Speed') | 650 | os.execute( 'mkdir -p rrd/' .. host .. '/Speed') |
@@ -647,12 +661,12 @@ APT.updateRRD = function(results, host, ip) | |||
647 | for i, p in pairs(APT.protocols) do | 661 | for i, p in pairs(APT.protocols) do |
648 | if nil ~= results[p] then | 662 | if nil ~= results[p] then |
649 | APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':' .. | 663 | APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':' .. |
650 | results[p]['Integrity'].errors .. ':' .. results[p]['Integrity'].warnings .. ':' .. | 664 | results[p]['Integrity'].errors .. ':' .. results[p]['Integrity'].warnings .. ':' .. results[p]['Integrity'].timeouts .. ':' .. |
651 | results[p]['Protocol'].errors .. ':' .. results[p]['Protocol'].warnings .. ':' .. | 665 | results[p]['Protocol'].errors .. ':' .. results[p]['Protocol'].warnings .. ':' .. results[p]['Protocol'].timeouts .. ':' .. |
652 | results[p]['Updated'].errors .. ':' .. results[p]['Updated'].warnings .. ':' .. | 666 | results[p]['Updated'].errors .. ':' .. results[p]['Updated'].warnings .. ':' .. results[p]['Updated'].timeouts .. ':' .. |
653 | results[p]['URLSanity'].errors .. ':' .. results[p]['URLSanity'].warnings) | 667 | results[p]['URLSanity'].errors .. ':' .. results[p]['URLSanity'].warnings .. ':' .. results[p]['URLSanity'].timeouts) |
654 | else | 668 | else |
655 | APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':U:U:U:U:U:U:U:U') | 669 | APT.rrd.update('rrd/' .. host .. '/' .. p:upper() .. '/Tests.rrd', APT.now .. ':U:U:U:U:U:U:U:U:U:U:U:U') |
656 | end | 670 | end |
657 | end | 671 | end |
658 | if nil ~= results.speed then | 672 | if nil ~= results.speed then |
diff --git a/apt-panopticon-update-data.lua b/apt-panopticon-update-data.lua index 57eddd9..ceef7f3 100755 --- a/apt-panopticon-update-data.lua +++ b/apt-panopticon-update-data.lua | |||
@@ -11,6 +11,35 @@ local arg, sendArgs = APT.parseArgs({...}) | |||
11 | 11 | ||
12 | local oldest = 0 | 12 | local oldest = 0 |
13 | 13 | ||
14 | local fixResults = function(f) | ||
15 | if APT.checkFile(f) then | ||
16 | local results = loadfile(f)() | ||
17 | results = APT.padResults(results) | ||
18 | for i, w in pairs(APT.protocols) do | ||
19 | tests = results[w] | ||
20 | if nil ~= tests.Redirects then | ||
21 | tests.redirects = tests.Redirects | ||
22 | tests.Redirects = nil | ||
23 | elseif nil == tests.redirects then | ||
24 | tests.redirects = {} | ||
25 | end | ||
26 | results[w] = tests | ||
27 | end | ||
28 | if nil ~= results.Redirects then | ||
29 | for i, w in pairs(APT.protocols) do | ||
30 | results[w].redirects = results.Redirects | ||
31 | end | ||
32 | results.Redirects = nil | ||
33 | end | ||
34 | local rfile, e = io.open(f, "w+") | ||
35 | if nil == rfile then C("opening results file - " .. e) else | ||
36 | rfile:write(APT.dumpTable(results, "", "results") .. "\nreturn results\n") | ||
37 | rfile:close() | ||
38 | end | ||
39 | end | ||
40 | end | ||
41 | |||
42 | |||
14 | local lock = 'apt-panopticon.lock' | 43 | local lock = 'apt-panopticon.lock' |
15 | while APT.checkFile(lock) do os.execute('sleep 10') end | 44 | while APT.checkFile(lock) do os.execute('sleep 10') end |
16 | os.execute('touch ' .. lock) | 45 | os.execute('touch ' .. lock) |
@@ -53,7 +82,6 @@ for l in files:lines() do | |||
53 | local f = l:sub(1, -8) .. "/" .. k .. ".lua" | 82 | local f = l:sub(1, -8) .. "/" .. k .. ".lua" |
54 | if APT.checkFile(f) then | 83 | if APT.checkFile(f) then |
55 | results = loadfile(f)() | 84 | results = loadfile(f)() |
56 | results = APT.padResults(results) | ||
57 | results['IPs'] = v.IPs | 85 | results['IPs'] = v.IPs |
58 | local rfile, e = io.open(f, "w+") | 86 | local rfile, e = io.open(f, "w+") |
59 | if nil == rfile then C("opening results file - " .. e) else | 87 | if nil == rfile then C("opening results file - " .. e) else |
@@ -63,6 +91,10 @@ for l in files:lines() do | |||
63 | end | 91 | end |
64 | end | 92 | end |
65 | end | 93 | end |
94 | local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') | ||
95 | for k in fls:lines() do | ||
96 | fixResults(k) | ||
97 | end | ||
66 | end | 98 | end |
67 | 99 | ||
68 | 100 | ||