mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Use totalval to decide which elements to esclude
This commit is contained in:
parent
1953552457
commit
0dc20931ff
1 changed files with 12 additions and 3 deletions
|
|
@ -1352,18 +1352,27 @@ end
|
|||
-- #################################################
|
||||
|
||||
function rrd2json_merge(ret, num)
|
||||
local i = 1
|
||||
-- if we are expanding an interface view, we want to concatenate
|
||||
-- jsons for single interfaces, and not for the view. Since view statistics
|
||||
-- are in ret[1], it suffices to aggregate jsons from index i >= 2
|
||||
local json = "["
|
||||
local first = true -- used to decide where to append commas
|
||||
while i <= num do
|
||||
|
||||
-- sort by "totalval" to get the top "num" results
|
||||
local by_totalval = {}
|
||||
for i = 1, #ret do
|
||||
by_totalval[i] = ret[i].totalval
|
||||
end
|
||||
|
||||
local ctr = 0
|
||||
|
||||
for i,_ in pairsByValues(by_totalval, rev) do
|
||||
if ctr >= num then break end
|
||||
if(debug_metric) then io.write("->"..i.."\n") end
|
||||
if not first then json = json.."," end
|
||||
json = json..ret[i].json
|
||||
i = i + 1
|
||||
first = false
|
||||
ctr = ctr + 1
|
||||
end
|
||||
json = json.."]"
|
||||
-- the (possibly aggregated) json always goes into ret[1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue