Merge pull request #6652 from jjm2473/upstream/dockerman-fix-stats-tab-blank

luci-app-dockerman: fix stats page always blank
This commit is contained in:
Jo-Philipp Wich 2023-11-01 11:41:00 +01:00 committed by GitHub
commit 408ff05c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -752,35 +752,40 @@ elseif action == "stats" then
local response = dk.containers:top({id = container_id, query = {ps_args="-aux"}}) local response = dk.containers:top({id = container_id, query = {ps_args="-aux"}})
local container_top local container_top
if response.code == 200 then if response.code ~= 409 then
container_top=response.body if response.code ~= 200 then
else
response = dk.containers:top({id = container_id}) response = dk.containers:top({id = container_id})
if response.code == 200 then
container_top=response.body
end
end end
if type(container_top) == "table" then if response.code ~= 200 then
s = m:section(SimpleSection) response = dk.containers:top({id = container_id, query = {ps_args="-ww"}})
s.container_id = container_id end
s.template = "dockerman/container_stats"
table_stats = { if response.code == 200 then
cpu={ container_top = response.body
end
local table_stats = {
cpu = {
key=translate("CPU Usage"), key=translate("CPU Usage"),
value='-' value='-'
}, },
memory={ memory = {
key=translate("Memory Usage"), key=translate("Memory Usage"),
value='-' value='-'
} }
} }
container_top = response.body
s = m:section(Table, table_stats, translate("Stats")) s = m:section(Table, table_stats, translate("Stats"))
s:option(DummyValue, "key", translate("Stats")).width="33%" s:option(DummyValue, "key", translate("Stats")).width="33%"
s:option(DummyValue, "value") s:option(DummyValue, "value")
top_section = m:section(Table, container_top.Processes, translate("TOP"))
s = m:section(SimpleSection)
s.container_id = container_id
s.template = "dockerman/container_stats"
end
if type(container_top) == "table" then
local top_section = m:section(Table, container_top.Processes, translate("TOP"))
for i, v in ipairs(container_top.Titles) do for i, v in ipairs(container_top.Titles) do
top_section:option(DummyValue, i, translate(v)) top_section:option(DummyValue, i, translate(v))
end end