--
-- (C) 2021 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local page_utils = require("page_utils")
local ebpf_utils = require "ebpf_utils"
sendHTTPContentTypeHeader('text/html')
page_utils.print_header_and_set_active_menu_entry(page_utils.menu_entries.hosts)
local page = _GET["page"]
if(page == nil) then page = "username_processes" end
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
local user_key = _GET["username"]
local host_info = url2hostinfo(_GET)
local uid = _GET["uid"]
local name
local ifstats = interface.getStats()
local refresh_rate
local have_nedge = ntop.isnEdge()
if have_nedge then
refresh_rate = 5
else
refresh_rate = interface.getStatsUpdateFreq(ifstats["id"])
end
if(user_key == nil) then
print("
"..i18n("user_info.missing_user_name_message").."
")
else
local title = ''
local nav_url = ntop.getHttpPrefix().."/lua/username_details.lua?username="..user_key.."&uid="..uid
if host_info and host_info["host"] then
name = hostinfo2label(host_info)
if isEmptyString(name) then
name = host_info["host"]
end
title = string.format("%s: %s", i18n("host_details.host"), name)
nav_url = nav_url.."&"..hostinfo2url(host_info)
end
title = title.." "..user_key
page_utils.print_navbar(title, nav_url,
{
{
active = page == "username_processes" or not page,
page_name = "username_processes",
label = i18n("user_info.processes"),
},
{
active = page == "username_ndpi",
page_name = "username_ndpi",
label = i18n("applications"),
},
{
active = page == "flows",
page_name = "flows",
label = '',
},
}
)
if(page == "username_processes") then
print [[
|
]] print(i18n("user_info.processes_overview")) print[[
| |
]]
print [[
]]
elseif(page == "username_ndpi") then
ebpf_utils.draw_ndpi_piecharts(ifstats, "get_username_data.lua", host_info, user_key, nil)
elseif page == "flows" then
ebpf_utils.draw_flows_datatable(ifstats, host_info, user_key, nil)
end
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")