From fb617ad2e22c3c7ad705cb6748da57b5417985b2 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 3 Dec 2019 06:27:15 +1000 Subject: Test and report speed. --- apt-panopticon-report-email-web.lua | 36 +++++++++++++++++++++++++++++++++--- apt-panopticon.lua | 12 +++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index fc1f345..131c803 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua @@ -75,6 +75,11 @@ dumpTableHTMLSub = function (table, space) return r end +local checkFile = function(f) + local h, e = io.open(f, "r") + if nil == h then return false else h:close(); return true end +end + local plurals = function(e, w) local result = "" if 1 == e then @@ -393,7 +398,7 @@ if nil == web then C("opening mirrors file - " .. e) else "https://pkgmaster.devuan.org/mirror_list.txt

\n" .. "

Due to the nature of the tests, some errors or warnings will be counted several times.   " .. "The links in the table and DNS list go to the detailed testing logs.

\n\n" .. - "
\n

==== package mirror status " .. os.date("!%Y-%m-%d %H:%M") .. " GMT ====

\n\n" .. + "
\n

==== package mirror status " .. os.date("!%Y-%m-%d %H:%M") .. " GMT ====

\n" .. "

[FAILED] or [OK]" .. " means the tested thing is supported for that mirror.

\n" .. @@ -407,7 +412,8 @@ if nil == web then C("opening mirrors file - " .. e) else "

The time in the Updated column is how often the mirror updates itself.

" .. "

Mirrors with a grey background are not active (though may be usable as part of the DNS-RR).

\n" .. "

[skip] means that the test hasn't been written yet.

\n" .. - "\n" + "
FTPHTTPHTTPSRSYNCDNS round robinProtocolURL sanityIntegrityUpdated
\n" .. + "\n" ) for k, v in orderedPairs(mirrors) do local results = loadfile("results/" .. k .. ".lua")() @@ -439,6 +445,7 @@ if nil == web then C("opening mirrors file - " .. e) else local updated = status(k, results, "Updated") local rate = v.Rate if nil ~= rate then updated = updated .. ' ' .. rate end + local min, max, spd = 999999999999, 0, '' -- DNS-RR test. if ("deb.devuan.org" ~= k) and (nil ~= mirrors["deb.devuan.org"]) then @@ -470,11 +477,34 @@ if nil == web then C("opening mirrors file - " .. e) else end end if "" == dns then dns = "[no]" end + + for i, mt in pairs({'Release', 'Packages', 'META'}) do + if checkFile("results/curl-" .. mt .. "-" .. k .. ".log") then + for l in io.lines("results/curl-" .. mt .. "-" .. k .. ".log") do + 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?)') + if nil ~= speed then + if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end + if 'k' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000' end + speed = tonumber(speed) + crrnt = tonumber(crrnt) + if speed < min and speed ~= 0 then min = speed end + if speed > max then max = speed end + if crrnt < min and crrnt ~= 0 then min = crrnt end + if crrnt > max then max = crrnt end + end + end + end + end + if 0 == max then + spd = '' + else + spd = string.format('', min, max) + end end web:write("\n") + " " .. spd .. "\n") if "" ~= v.Active then web:write("\n") end diff --git a/apt-panopticon.lua b/apt-panopticon.lua index d2fa9b9..8566dad 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -745,9 +745,9 @@ local downloadLock = "flock -n results/curl-" local download = "curl --connect-timeout " .. options.timeout.value .. " --create-dirs -f -L --max-time " .. options.maxtime.value .. " -z 'results/stamp.old' -v -R " local downloads = function(host, URL, release, list) if nil == URL then URL = "" end - local lock = "%s-" .. host .. ".lock" - local log = " --stderr results/curl-%s_" .. host .. ".log" - local cm = "ionice -c3 nice -n 19 " .. downloadLock .. lock:format("META") .. " " .. download .. log:format("META") .. " -K results/" .. host .. ".curl" + local lock = "META-" .. host .. ".lock" + local log = " --stderr results/curl-META-" .. host .. ".log" + local cm = "ionice -c3 nice -n 19 " .. downloadLock .. lock .. " " .. download .. log .. " -K results/" .. host .. ".curl" if testing("IPv4") and (not testing("IPv6")) then cm = cm .. ' -4' end if (not testing("IPv4")) and testing("IPv6") then cm = cm .. ' -6' end f, e = io.open("results/" .. host .. ".curl", "a+") @@ -968,7 +968,8 @@ if 0 < #arg then if 4 > (totalTimeouts) then if origin and (options.roundRobin.value ~= pu.host) then while 0 < checkExes(downloadLock .. "META-" .. pu.host .. ".lock") do os.execute("sleep 10") end - os.execute("rm -f results/" .. pu.host .. ".curl; rm results/curl-" .. "META-" .. pu.host .. ".lock") + os.execute( "rm -f results/" .. pu.host .. ".curl; rm results/curl-META-" .. pu.host .. ".lock; " .. + "mv results/curl-META-" .. pu.host .. ".log results/curl-Release-" .. pu.host .. ".log") for i, n in pairs(releases) do for l, o in pairs(releaseFiles) do if repoExists(i .. o) then @@ -998,7 +999,8 @@ if 0 < #arg then downloads(pu.host, pu.path, "", "") while 0 < checkExes(downloadLock .. "META-" .. pu.host .. ".lock") do os.execute("sleep 10") end - os.execute("rm -f results/" .. pu.host .. ".curl; rm results/curl-" .. "META-" .. pu.host .. ".lock") + os.execute( "rm -f results/" .. pu.host .. ".curl; rm results/curl-META-" .. pu.host .. ".lock; " .. + "mv results/curl-META-" .. pu.host .. ".log results/curl-Packages-" .. pu.host .. ".log") for i, n in pairs(releases) do local dfile, e = io.open('results/NEW_Release_' .. n .. '.txt', "r") -- cgit v1.1
FTPHTTPHTTPSRSYNCDNS round robinProtocolURL sanityIntegrityUpdatedSpeed
%d ->%d" .. ftp .. " " .. http .. " " .. https .. " " .. rsync .. " " .. dns .. " " .. protocol .. " " .. sanity .. - " " .. integrity .. " " .. updated .. "
" .. integrity .. " " .. updated .. " 
" .. active .. "