-- -- (C) 2013-18 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") select_keys = _GET["select_keys_clause"] select_values = _GET["select_values_clause"] where = _GET["where_clause"] maxhits = _GET["maxhits_clause"] topk = _GET["topk_clause"] begin_time = _GET["begin_time_clause"] end_time = _GET["end_time_clause"] approx_search = _GET["approx_search"] if(_GET["flow_clause"] == "aggregated_flows") then aggregated_flows = true else aggregated_flows = false end if(where == nil) then where = "" end if((approx_search == nil) or (approx_search == "true")) then approx_search = true else approx_search = false end if((select_keys == nil) or (select_keys == "")) then select_keys = "IPV4_SRC_ADDR,IPV4_DST_ADDR,L7_PROTO" end if((select_values == nil) or (select_values == "")) then select_values = "BYTES" end if(topk == nil) then topk = "SUM" end if((maxhits == nil) or (maxhits == "")) then maxhits = "10" end if((begin_time == nil) or (begin_time == "")) then begin_time = "now-1h" end if((end_time == nil) or (end_time == "")) then end_time = "now" end -- Zap spaces select_keys = select_keys:gsub("%s+", "") select_values = select_values:gsub("%s+", "") -- where = where:gsub("%s+", "") print('

[ Flows ] [ Interface ]

') print [[
Flow keys. Example: IPV4_SRC_ADDR,IPV4_DST_ADDR....
Example: BYTES
Use field <operatore> where operator could be <, >, =, !=
]] bottomToTopSort = false res = interface.nIndexTopK(aggregated_flows, begin_time, end_time, select_keys, select_values, where, topk, 0, tonumber(maxhits), bottomToTopSort, approx_search) -- tprint(res) if(res) then if(type(res) == "string") then print("

 

ERROR: "..res.."") else if(res.info.duration == 0) then res.info.duration = " < 1" end print("

Query perfomed in "..res.info.duration.." msec
") print("

\n") print("") for k, row in pairs(res.columns) do print("") end print("\n") for k, row in pairs(res.results) do print("") -- print("") for k, v in pairs(row) do print("") end print("\n") end print("
"..row.."
"..k..""..v.."
\n") end else print("No result") end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")