Browse Source

Tweak the dumpTable() arguments a little.

master
onefang 3 years ago
parent
commit
6e868b6382
  1. 16
      apt-panopticommon.lua
  2. 2
      apt-panopticon-nagios.lua
  3. 4
      apt-panopticon-report-email-web.lua
  4. 4
      apt-panopticon-update-data.lua
  5. 8
      apt-panopticon.lua

16
apt-panopticommon.lua

@ -182,8 +182,6 @@ APT.parseArgs = function(args)
return arg, sendArgs
end
--print(APT.dumpTable(APT.options, "", "options"))
--[[ Ordered table iterator, allow to iterate on the natural order of the keys of a table.
@ -232,7 +230,8 @@ function APT.orderedPairs(t)
end
-- Use this to dump a table to a string, with HTML.
APT.dumpTableHTML = function (table, space, name)
APT.dumpTableHTML = function (table, name, space)
if nil == space then space = '' end
local r = name .. "\n"
r = r .. dumpTableHTMLSub(table, space .. " ")
r = r .. space .. ""
@ -243,9 +242,9 @@ dumpTableHTMLSub = function (table, space)
for k, v in APT.orderedPairs(table) do
if type(v) == "table" then
if " " == space then
r = r .. space .. APT.dumpTableHTML(v, space, k .. "<ul>") .. "</ul>\n"
r = r .. space .. APT.dumpTableHTML(v, k .. "<ul>", space) .. "</ul>\n"
else
r = r .. "<li>" .. space .. APT.dumpTableHTML(v, space, k .. "<ul>") .. "</ul></li>\n"
r = r .. "<li>" .. space .. APT.dumpTableHTML(v, k .. "<ul>", space) .. "</ul></li>\n"
end
else
r = r .. space .. "<li>" .. k .. "</li>\n"
@ -255,7 +254,8 @@ dumpTableHTMLSub = function (table, space)
end
-- Use this to dump a table to a string.
APT.dumpTable = function (table, space, name)
APT.dumpTable = function (table, name, space)
if nil == space then space = '' end
local r = ""
if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end
r = r .. space .. "{\n"
@ -268,7 +268,7 @@ dumpTableSub = function (table, space)
for k, v in pairs(table) do
if type(k) == "string" then k = '"' .. k .. '"' end
if type(v) == "table" then
r = r .. APT.dumpTable(v, space, k)
r = r .. APT.dumpTable(v, k, space)
elseif type(v) == "string" then
local bq = '"'
local eq = '"'
@ -331,7 +331,7 @@ APT.logOpen = function(host, a2, a3)
APT.logFile:write("<html><head>\n")
APT.logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n")
APT.logFile:write("<pre>\n")
APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments'))
APT.logFile:write(APT.dumpTable(APT.args, 'Arguments'))
APT.logFile:write("</pre>\n")
else
return false

2
apt-panopticon-nagios.lua

@ -300,7 +300,7 @@ if arguments["verbose"].value > 1 then
print("\nCheckGeneric.lua arguments -")
for k, v in pairs(arguments) do
if type(v.value) == "table" then
APT.dumpTable(v.value, "", " --" .. k)
APT.dumpTable(v.value, " --" .. k)
elseif type(v.value) == "boolean" then
if (v.value) then
printf(" --%s: true\n", k)

4
apt-panopticon-report-email-web.lua

@ -517,7 +517,7 @@ if nil == web then C("opening mirrors file - " .. e) else
"pkgmaster.devuan.org is the master mirror, all the others sync to it. &nbsp; " ..
"</p>\n"
)
web:write(APT.dumpTableHTML(m, "", ""))
web:write(APT.dumpTableHTML(m, ""))
web:write( "\n<br>\n<br>\n<h2>==== graphs: ====</h2>\n" ..
"<img src='speed.png'>\n<br>\n<p><a href='../apt-panopticon_cgp/'>More graphs.</a> with greater detail.</p><hr>\n\n")
@ -636,7 +636,7 @@ if nil == web then C("opening mirrors file - " .. e) else
end
m[log .. " DNS entries -" .. redirs(APT.mirrors, k)] = n
end
web:write(APT.dumpTableHTML(m, "", ""))
web:write(APT.dumpTableHTML(m, ""))
web:write( "<hr>\n<hr>\n<p>The <a href='Report-email.txt'>email report</a>. &nbsp; " ..
"All <a href='../results'>the logs and other output</a>. &nbsp; " ..

4
apt-panopticon-update-data.lua

@ -33,7 +33,7 @@ local fixResults = function(f)
end
local rfile, e = io.open(f, "w+")
if nil == rfile then C("opening results file - " .. e) else
rfile:write(APT.dumpTable(results, "", "results") .. "\nreturn results\n")
rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n")
rfile:close()
end
end
@ -86,7 +86,7 @@ for l in files:lines() do
results['IPs'] = v.IPs
local rfile, e = io.open(f, "w+")
if nil == rfile then C("opening results file - " .. e) else
rfile:write(APT.dumpTable(results, "", "results") .. "\nreturn results\n")
rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n")
rfile:close()
end
end

8
apt-panopticon.lua

@ -624,7 +624,7 @@ local getMirrors = function ()
end
local file, e = io.open("results/mirrors.lua", "w+")
if nil == file then C("opening mirrors file - " .. e) else
file:write(APT.dumpTable(mirrors, "", "mirrors") .. "\nreturn mirrors\n")
file:write(APT.dumpTable(mirrors, "mirrors") .. "\nreturn mirrors\n")
file:close()
end
return mirrors
@ -1045,7 +1045,7 @@ if 0 < #arg then
if "" ~= ip then f = f .. "_" .. ip end
local rfile, e = io.open("results/" .. f .. ".lua", "w+")
if nil == rfile then C("opening results file - " .. e) else
rfile:write(APT.dumpTable(APT.results, "", "results") .. "\nreturn results\n")
rfile:write(APT.dumpTable(APT.results, "results") .. "\nreturn results\n")
rfile:close()
end
@ -1190,7 +1190,7 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
end
local file, e = io.open("results/debians.lua", "w+")
if nil == file then C("opening debians file - " .. e) else
file:write(APT.dumpTable(debians, "", "debians") .. "\nreturn debians\n")
file:write(APT.dumpTable(debians, "debians") .. "\nreturn debians\n")
file:close()
end
@ -1204,7 +1204,7 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
end
local file, e = io.open("results/mirrors.lua", "w+")
if nil == file then C("opening mirrors file - " .. e) else
file:write(APT.dumpTable(APT.mirrors, "", "mirrors") .. "\nreturn mirrors\n")
file:write(APT.dumpTable(APT.mirrors, "mirrors") .. "\nreturn mirrors\n")
file:close()
end

Loading…
Cancel
Save