Fixes host packet page is blank (#5824)

This commit is contained in:
MatteoBiscosi 2021-09-21 15:56:40 +02:00
parent 529ee2c8e5
commit 7fbef1798f

View file

@ -966,37 +966,36 @@ end
local tots = 0 for key, value in pairs(host["pktStats.sent"]["size"]) do tots = tots + value end
local totr = 0 for key, value in pairs(host["pktStats.recv"]["size"]) do totr = totr + value end
if((tots > 0) or (totr > 0)) then
print('<tr><th class="text-start">'..i18n("packets_page.sent_vs_rcvd_distribution")..'</th>')
if(tots > 0) then
print('<td colspan=1><div class="pie-chart" id="sizeSentDistro"></div></td>')
else
print('<td colspan=1>&nbsp;</td>')
print('<td colspan=1>~</td>')
end
if(totr > 0) then
print('<td colspan=1><div class="pie-chart" id="sizeRecvDistro"></div></td>')
else
print('<td colspan=1>&nbsp;</td>')
print('<td colspan=1>~</td>')
end
print('</tr>')
end
local has_tcp_distro = (host["tcp.packets.rcvd"] + host["tcp.packets.sent"] > 0)
local has_arp_distro = (not isEmptyString(host["mac"])) and (host["mac"] ~= "00:00:00:00:00:00") and (ifs.type ~= "zmq")
if(has_tcp_distro and has_arp_distro) then
print('<tr><th class="text-start">'..i18n("packets_page.tcp_flags_vs_arp_distribution")..'</th><td colspan=1><div class="pie-chart" id="flagsDistro"></div></td><td colspan=1><div class="pie-chart" id="arpDistro"></div></td></tr>')
print('<tr><th class="text-start">'..i18n("packets_page.tcp_flags_vs_arp_distribution")..'</th><td colspan=1><div class="pie-chart" id="flagsDistro"></div></td><td colspan=1><div class="pie-chart" id="arpDistro"></div></td></tr>')
else
if (has_tcp_distro) then
print('<tr><th class="text-start">'..i18n("packets_page.tcp_flags_distribution")..'</th><td colspan=5><div class="pie-chart" id="flagsDistro"></div></td></tr>')
end
if (has_arp_distro) then
print('<tr><th class="text-start">'..i18n("packets_page.tcp_flags_distribution")..'</th><td colspan=5><div class="pie-chart" id="flagsDistro"></div></td></tr>')
elseif (has_arp_distro) then
if (macinfo ~= nil) and (macinfo["arp_requests.sent"] + macinfo["arp_requests.rcvd"] + macinfo["arp_replies.sent"] + macinfo["arp_replies.rcvd"] > 0) then
print('<tr><th class="text-start">'..i18n("packets_page.arp_distribution")..'</th><td colspan=5><div class="pie-chart" id="arpDistro"></div></td></tr>')
end
else
print('<tr><th class="text-start">'..i18n("packets_page.tcp_flags_distribution")..'</th>') print('<td colspan=5>~</td></tr>')
end
end
end
hostinfo2json(host_info)
print [[