Improves JSON data retrieval for historical top talkers

This commit is contained in:
Simone Mainardi 2016-02-02 19:06:53 +01:00
parent e8a3d43065
commit 7b2057eaec
2 changed files with 42 additions and 25 deletions

View file

@ -248,13 +248,26 @@ local function getHistoricalTopTalkersInInterval(ifid, ifname, epoch_start, epoc
end
end
end
end
::next_vlan::
end
::next_record::
end
-- tprint(res)
return json.encode(res, nil)
-- reformat the output so that it becomes easier to parse
local pretty_res = {}
for direction, hosts in pairs(res) do
local t = {}
for addr, traffic in pairs(hosts) do
table.insert(pretty_res, {["addr"] = addr, ["bytes"] = traffic, ["direction"] = direction})
end
end
res = pretty_res
return res
end
top_talkers_intf.name = "Top Talkers"