-- -- (C) 2013-20 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path -- io.write ("Session:".._SESSION["session"].."\n") require "lua_utils" local page_utils = require("page_utils") local is_system_interface = page_utils.is_system_view() interface.select(ifname) if (is_system_interface) then print(ntop.httpRedirect(ntop.getHttpPrefix().."/lua/system_stats.lua")) return end if(ntop.isnEdge()) then package.path = dirs.installdir .. "/pro/scripts/lua/nedge/modules/?.lua;" .. package.path local nf_config = require("nf_config"):readable() if nf_config.isFirstStart() then print(ntop.httpRedirect(ntop.getHttpPrefix().."lua/pro/nedge/system_setup/interfaces.lua")) return end end if(ntop.isPro()) then if interface.isPcapDumpInterface() == false then print(ntop.httpRedirect(ntop.getHttpPrefix().."/lua/pro/dashboard.lua")) return else -- it doesn't make sense to show the dashboard for pcap files... print(ntop.httpRedirect(ntop.getHttpPrefix().."/lua/if_stats.lua?ifid="..getInterfaceId(ifname))) return end end sendHTTPContentTypeHeader('text/html') page_utils.set_active_menu_entry(page_utils.menu_entries.traffic_dashboard) -- NOTE: in the home page, footer.lua checks the ntopng version -- so in case we change it, footer.lua must also be updated dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") ifstats = interface.getStats() is_loopback = interface.isLoopback() iface_id = interface.name2id(ifname) -- Load from or set in redis the refresh frequency for the top flow sankey refresh = _GET["refresh"] refresh_key = 'ntopng.prefs.'.._SESSION["user"]..'.'..ifname..'.top_flow_refresh' if (refresh ~= nil) then ntop.setCache(refresh_key,refresh) else refresh = ntop.getCache(refresh_key) end -- Default frequency (ms) if (refresh == '') then refresh = 5000 end -- print([[
]]) page = _GET["page"] if(page == nil) then if(not(is_loopback)) then page = "TopFlowTalkers" else page = "TopHosts" end end if((ifstats ~= nil) and (ifstats.stats.packets > 0)) then local nav_url = ntop.getHttpPrefix()..'/?ifid='..interface.getId() local title = i18n("index_page.dashboard") page_utils.print_navbar(title, nav_url, { { active = page == "TopFlowTalkers" or not page, page_name = "TopFlowTalkers", label = i18n("talkers"), }, { active = page == "TopHosts", page_name = "TopHosts", label = i18n("index_page.hosts"), }, { active = page == "TopPorts", page_name = "TopPorts", label = i18n("ports"), }, { active = page == "TopApplications", page_name = "TopApplications", label = i18n("index_page.applications"), }, } ) if(page == "TopFlowTalkers") then print('
\n

'..i18n("index_page.top_flow_talkers")..'

\n') print('
') dofile(dirs.installdir .. "/scripts/lua/inc/sankey.lua") print('\n



\n') print [[
]] print(i18n("index_page.refresh_frequency")) print[[:
]] if (refresh ~= '0') then print [[]] print(i18n("index_page.live_update")) print [[:]] print[[
]] else print [[]] print(i18n("index_page.refresh")) print [[:]] print[[
]] end print [[

]] print [[ ]] else ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_" .. page .. ".inc") end --ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_top.inc") -- ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_bottom.inc") else print("
"..i18n("index_page.no_packet_warning",{ifname=getHumanReadableInterfaceName(ifname),countdown=""}).."
") end print([[
]]) dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")