From daca02cdef0abe2557b7a6a2abae82a159116157 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 4 Dec 2019 08:14:16 +1000 Subject: Move the speed calc to the main script. --- apt-panopticon.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'apt-panopticon.lua') 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 if not keep then os.execute("rm -fr results/" .. pu.host) end os.execute('rm STATUS_' .. pu.host .. '* 2>/dev/null') end + + local min, max, spd = 999999999999, 0 + for i, mt in pairs({'Release', 'Packages', 'META'}) do + if checkFile("results/curl-" .. mt .. "-" .. pu.host .. ".log") then + for l in io.lines("results/curl-" .. mt .. "-" .. pu.host .. ".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 + results["speed"] = {min = min, max = max} + local f = pu.host if "" ~= ip then f = f .. "_" .. ip end local rfile, e = io.open("results/" .. f .. ".lua", "w+") -- cgit v1.1