diff options
author | onefang | 2019-12-04 08:14:16 +1000 |
---|---|---|
committer | onefang | 2019-12-04 08:14:16 +1000 |
commit | daca02cdef0abe2557b7a6a2abae82a159116157 (patch) | |
tree | 7420ddcf436331b051bb72ac813f0f8b7092eccb | |
parent | Don't log some of the executes. (diff) | |
download | apt-panopticon-daca02cdef0abe2557b7a6a2abae82a159116157.zip apt-panopticon-daca02cdef0abe2557b7a6a2abae82a159116157.tar.gz apt-panopticon-daca02cdef0abe2557b7a6a2abae82a159116157.tar.bz2 apt-panopticon-daca02cdef0abe2557b7a6a2abae82a159116157.tar.xz |
Move the speed calc to the main script.
-rwxr-xr-x | apt-panopticon-report-email-web.lua | 45 | ||||
-rwxr-xr-x | apt-panopticon.lua | 21 |
2 files changed, 38 insertions, 28 deletions
diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index 03970ac..9e9d818 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua | |||
@@ -244,17 +244,22 @@ local collate = function(host, ip, results) | |||
244 | local rs = loadfile(f)() | 244 | local rs = loadfile(f)() |
245 | for k, v in pairs(rs) do | 245 | for k, v in pairs(rs) do |
246 | if "table" == type(v) then | 246 | if "table" == type(v) then |
247 | for i, u in pairs(v) do | 247 | if "speed" == k then |
248 | if "table" == type(u) then | 248 | if v.min < results.speed.min then results.speed.min = v.min end |
249 | for h, t in pairs(u) do | 249 | if v.max > results.speed.max then results.speed.max = v.max end |
250 | local a = results[k][h] | 250 | else |
251 | for i, u in pairs(v) do | ||
252 | if "table" == type(u) then | ||
253 | for h, t in pairs(u) do | ||
254 | local a = results[k][h] | ||
255 | if nil == a then a = 0 end | ||
256 | results[k][h] = a + t | ||
257 | end | ||
258 | else | ||
259 | local a = results[k][i] | ||
251 | if nil == a then a = 0 end | 260 | if nil == a then a = 0 end |
252 | results[k][h] = a + t | 261 | results[k][i] = a + u |
253 | end | 262 | end |
254 | else | ||
255 | local a = results[k][i] | ||
256 | if nil == a then a = 0 end | ||
257 | results[k][i] = a + u | ||
258 | end | 263 | end |
259 | end | 264 | end |
260 | else | 265 | else |
@@ -445,7 +450,9 @@ if nil == web then C("opening mirrors file - " .. e) else | |||
445 | local updated = status(k, results, "Updated") | 450 | local updated = status(k, results, "Updated") |
446 | local rate = v.Rate | 451 | local rate = v.Rate |
447 | if nil ~= rate then updated = updated .. ' ' .. rate end | 452 | if nil ~= rate then updated = updated .. ' ' .. rate end |
448 | local min, max, spd = 999999999999, 0, '' | 453 | local min = tonumber(results.speed.min) |
454 | local max = tonumber(results.speed.max) | ||
455 | local spd = '' | ||
449 | 456 | ||
450 | -- DNS-RR test. | 457 | -- DNS-RR test. |
451 | if ("deb.devuan.org" ~= k) and (nil ~= mirrors["deb.devuan.org"]) then | 458 | if ("deb.devuan.org" ~= k) and (nil ~= mirrors["deb.devuan.org"]) then |
@@ -476,25 +483,7 @@ if nil == web then C("opening mirrors file - " .. e) else | |||
476 | end | 483 | end |
477 | end | 484 | end |
478 | end | 485 | end |
479 | if "" == dns then dns = "[<font color='grey'><b>no</b></font>]" end | ||
480 | 486 | ||
481 | for i, mt in pairs({'Release', 'Packages', 'META'}) do | ||
482 | if checkFile("results/curl-" .. mt .. "-" .. k .. ".log") then | ||
483 | for l in io.lines("results/curl-" .. mt .. "-" .. k .. ".log") do | ||
484 | local speed, crrnt = l:match('^%c *%d+ +%d+k? +%d+ +%d+k? +%d+ +%d+ +(%d+k?) +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +(%d+k?)') | ||
485 | if nil ~= speed then | ||
486 | if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end | ||
487 | if 'k' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000' end | ||
488 | speed = tonumber(speed) | ||
489 | crrnt = tonumber(crrnt) | ||
490 | if speed < min and speed ~= 0 then min = speed end | ||
491 | if speed > max then max = speed end | ||
492 | if crrnt < min and crrnt ~= 0 then min = crrnt end | ||
493 | if crrnt > max then max = crrnt end | ||
494 | end | ||
495 | end | ||
496 | end | ||
497 | end | ||
498 | if 0 == max then | 487 | if 0 == max then |
499 | spd = '<td></td><td></td>' | 488 | spd = '<td></td><td></td>' |
500 | else | 489 | else |
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 7da7380..5aa1e8d 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -1073,6 +1073,27 @@ if 0 < #arg then | |||
1073 | if not keep then os.execute("rm -fr results/" .. pu.host) end | 1073 | if not keep then os.execute("rm -fr results/" .. pu.host) end |
1074 | os.execute('rm STATUS_' .. pu.host .. '* 2>/dev/null') | 1074 | os.execute('rm STATUS_' .. pu.host .. '* 2>/dev/null') |
1075 | end | 1075 | end |
1076 | |||
1077 | local min, max, spd = 999999999999, 0 | ||
1078 | for i, mt in pairs({'Release', 'Packages', 'META'}) do | ||
1079 | if checkFile("results/curl-" .. mt .. "-" .. pu.host .. ".log") then | ||
1080 | for l in io.lines("results/curl-" .. mt .. "-" .. pu.host .. ".log") do | ||
1081 | local speed, crrnt = l:match('^%c *%d+ +%d+k? +%d+ +%d+k? +%d+ +%d+ +(%d+k?) +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +(%d+k?)') | ||
1082 | if nil ~= speed then | ||
1083 | if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end | ||
1084 | if 'k' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000' end | ||
1085 | speed = tonumber(speed) | ||
1086 | crrnt = tonumber(crrnt) | ||
1087 | if speed < min and speed ~= 0 then min = speed end | ||
1088 | if speed > max then max = speed end | ||
1089 | if crrnt < min and crrnt ~= 0 then min = crrnt end | ||
1090 | if crrnt > max then max = crrnt end | ||
1091 | end | ||
1092 | end | ||
1093 | end | ||
1094 | end | ||
1095 | results["speed"] = {min = min, max = max} | ||
1096 | |||
1076 | local f = pu.host | 1097 | local f = pu.host |
1077 | if "" ~= ip then f = f .. "_" .. ip end | 1098 | if "" ~= ip then f = f .. "_" .. ip end |
1078 | local rfile, e = io.open("results/" .. f .. ".lua", "w+") | 1099 | local rfile, e = io.open("results/" .. f .. ".lua", "w+") |