From b35794808bd93a3489565c3b9886a7c995463623 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 24 Dec 2019 21:20:51 +1000 Subject: Everyone gets a car, er I mean linky! --- apt-panopticommon.lua | 13 +++++++------ apt-panopticon.lua | 39 ++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index 54e2be1..ea6346e 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua @@ -317,13 +317,14 @@ APT.html = false APT.logName = function(host, a2, a3) local name = host - if nil ~= a2 then name = name .. "_" .. a2 end - if nil ~= a3 then name = name .. "_" .. a3 end - return 'results/LOG_' .. name .. '.html' + if (nil ~= a2) and ('' ~= a2) then name = name .. "_" .. a2 end + if (nil ~= a3) and ('' ~= a3) then name = name .. "_" .. a3 end + name = 'LOG_' .. name .. '.html' + return {'results/' .. name, '' .. name:gsub("/", "_") .. ''} end APT.logOpen = function(host, a2, a3) - local name = APT.logName(host, a2, a3) + local name = APT.logName(host, a2, a3)[1] if APT.checkFile(name) then return false end APT.logFile, e = io.open(name, "a+") if nil == APT.logFile then C('opening log file (' .. name .. ') - ' .. e); return false end @@ -422,7 +423,7 @@ APT.testing = function(t, host) end APT.execute = function (s) - D(" executing
" .. s .. "
") + D(" executing -   " .. s .. "") --[[ Damn os.execute() Lua 5.1 says it returns "a status code, which is system-dependent" Lua 5.2 says it returns true/nil, "exit"/"signal", the status code. @@ -441,7 +442,7 @@ APT.execute = function (s) end APT.fork = function(s) - D(" forking
" .. s .. "
") + D(" forking -   " .. s .. "") os.execute(s .. " &") end diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 649346a..13adead 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -377,7 +377,8 @@ checkHEAD = function (host, URL, r, retry, sanity) if 'https' == pu.scheme then extraArgs = extraArgs .. ' --tests=-http' end if 'http' == pu.scheme then extraArgs = extraArgs .. ' --tests=-https' end I(" Now checking redirected host " .. u) - APT.fork("ionice -c3 nice -n 19 " .. downloadLock .. "REDIR-" .. check .. ".log" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file) + APT.fork("ionice -c3 nice -n 19 " .. downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file) + D('logging to ' .. APT.logName(pu.host, nil, file)[2]) end end end @@ -451,6 +452,7 @@ checkHost = function (orig, host, path, ip, file) if orig == host then D("checkHost " .. orig .. "" .. file) APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " -o " .. orig .. path .. " " .. file) + D('logging to ' .. APT.logName(ph.host, nil, file)[2]) else D("checkHost " .. orig .. " -> " .. host) end end end @@ -495,15 +497,16 @@ local download = "curl" .. " --fail-early" .. " --max-time " .. APT.options.maxtime.value .. " --retry " .. APT.options.retries.value .. - " -R -v -z 'results/stamp.old' " + " -R -v -z 'results/stamp.old' --stderr results/" local downloads = function(host, URL, meta, release, list) if nil == URL then URL = "" end - local lock = meta .. "-" .. host .. ".log" - local log = " --stderr results/curl-" .. meta .. "-" .. host .. ".log" - local cm = "ionice -c3 nice -n 19 " .. downloadLock .. lock .. " " .. download .. log .. " -K results/curl-" .. meta .. '-' .. host .. ".files" + local files = 'curl-' .. meta .. '-' .. host .. '.files.txt' + local lock = meta .. "-" .. host .. ".log.txt" + local log = "curl-" .. meta .. "-" .. host .. ".log.txt" + local cm = "ionice -c3 nice -n 19 " .. downloadLock .. lock .. " " .. download .. log .. " -K results/" .. files if APT.testing("IPv4") and (not APT.testing("IPv6")) then cm = cm .. ' -4' end if (not APT.testing("IPv4")) and APT.testing("IPv6") then cm = cm .. ' -6' end - f, e = io.open("results/curl-" .. meta .. '-' .. host .. ".files", "a+") + f, e = io.open("results/curl-" .. meta .. '-' .. host .. ".files.txt", "a+") if nil == f then C("opening curl downloads list file - " .. e); return end if nil ~= list then @@ -531,6 +534,7 @@ local downloads = function(host, URL, meta, release, list) end f:close() APT.fork(cm) + D('logging to ' .. log .. ', with these files') end @@ -847,16 +851,16 @@ drwxr-x--- 2 www-data www-data 4096 2019-12-23 01:02:57.000000000 +1000 aptly ]] os.execute('sleep 1') -- Wait for things to start up before checking for them. - while 0 < APT.checkExes(downloadLock .. list.out .. "-" .. host .. ".log") do - D('*<* About to yield coroutine while waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log') + while 0 < APT.checkExes(downloadLock .. list.out .. "-" .. host .. ".log.txt") do + D('*<* About to yield coroutine while waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log.txt') coroutine.yield() - D('*>* Resumed coroutine while waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log') + D('*>* Resumed coroutine while waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log.txt') end - D('*>* Resumed coroutine NO LONGER waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log') + D('*>* Resumed coroutine NO LONGER waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log.txt') local min, max, spd = 999999999999, 0 - if APT.checkFile("results/curl-" .. list.out .. "-" .. host .. ".log") then - for l in io.lines("results/curl-" .. list.out .. "-" .. host .. ".log") do + if APT.checkFile("results/curl-" .. list.out .. "-" .. host .. ".log.txt") then + for l in io.lines("results/curl-" .. list.out .. "-" .. host .. ".log.txt") 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 @@ -869,7 +873,7 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. if crrnt > max then max = crrnt end end if l:find('timed out') ~= nil then - E(" TIMEOUT " .. timeouts + 1 .. ', details in curl-' .. list.out .. '-' .. host .. '.log', 'http', '', host) + E(" TIMEOUT " .. timeouts + 1 .. ', details in curl-' .. list.out .. '-' .. host .. '.log.txt', 'http', '', host) timeouts = timeouts + 1 APT.results["timeout"] = true end @@ -943,6 +947,7 @@ if 0 < #arg then elseif v1 == "AAAA" then if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k1 .. " " .. file) end end + D('logging to ' .. APT.logName(pu.host, k1, file)[2]) end else if v == "A" then @@ -950,6 +955,7 @@ if 0 < #arg then elseif v == "AAAA" then if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file) end end + D('logging to ' .. APT.logName(pu.host, k, file)[2]) end end end @@ -990,9 +996,9 @@ if 0 < #arg then if APT.origin and APT.options.referenceSite.value ~= pu.host then os.execute('sleep 1') -- Wait for things to start up before checking for them. - while 0 < APT.checkExes(downloadLock .. "Release-" .. pu.host .. ".log") do os.execute("sleep 10") end - while 0 < APT.checkExes(downloadLock .. "Packages-" .. pu.host .. ".log") do os.execute("sleep 10") end - while 0 < APT.checkExes(downloadLock .. "package-" .. pu.host .. ".log") do os.execute("sleep 10") end + while 0 < APT.checkExes(downloadLock .. "Release-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end + while 0 < APT.checkExes(downloadLock .. "Packages-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end + while 0 < APT.checkExes(downloadLock .. "package-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end os.execute("sleep 5") if not APT.keep then os.execute("rm -fr results/" .. pu.host .. " 2>/dev/null") end os.execute('rm results/STATUS_' .. pu.host .. '_* 2>/dev/null') @@ -1012,7 +1018,6 @@ else if nil ~= dt then os.execute('mkdir -p results_' .. dt .. '; rm -f results; ln -s results_' .. dt .. ' results 2>/dev/null') end os.execute('if [ -f results/stamp ]; then mv results/stamp results/stamp.old; else touch results/stamp.old -t 199901010000; fi; touch results/stamp') if not APT.keep then - os.execute("rm -f results/*.log 2>/dev/null") os.execute("rm -f results/*.html 2>/dev/null") os.execute("rm -f results/*.txt 2>/dev/null") end -- cgit v1.1