ntopng/scripts/lua/get_top_realtime.lua
emanuele-f 92b9991d92 Fix realtime top asn and hosts senders view
The view was broken after changes in commits:
	- 9b4e1060e6
	- 6635d1a716
2018-01-23 19:28:52 +01:00

37 lines
825 B
Lua

--
-- (C) 2013-17 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local json = require("dkjson")
local top_talkers_utils = require("top_talkers_utils")
local direction = _GET["senders_receivers"] or "senders"
sendHTTPContentTypeHeader('text/html')
local top_type = _GET["module"]
local data = {}
local json_res = top_talkers_utils.makeTopJson(ifname, false --[[ do not save checkpoint as we are not in minute.lua ]])
if json_res ~= nil then
local res = json.decode(json_res)
if res and res.vlan[1] then
res = res.vlan[1]
if top_type == "top_asn" then
res = res.asn[1]
else
res = res.hosts[1]
end
if res ~= nil then
data = res[direction]
end
end
end
print(json.encode(data))