--
-- (C) 2013-18 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
if((dirs.scriptdir ~= nil) and (dirs.scriptdir ~= "")) then package.path = dirs.scriptdir .. "/lua/modules/?.lua;" .. package.path end
require "lua_utils"
local alerts_api = require("alerts_api")
local recording_utils = require "recording_utils"
local remote_assistance = require "remote_assistance"
local telemetry_utils = require "telemetry_utils"
local ts_utils = require("ts_utils_core")
local is_admin = isAdministrator()
print[[
]]
if ntop.isnEdge() then
dofile(dirs.installdir .. "/pro/scripts/lua/nedge/inc/menu.lua")
return
end
local template = require "template_utils"
prefs = ntop.getPrefs()
local iface_names = interface.getIfNames()
-- tprint(iface_names)
num_ifaces = 0
for k,v in pairs(iface_names) do
num_ifaces = num_ifaces+1
end
print [[
]]
interface.select(ifname)
local ifs = interface.getStats()
local is_pcap_dump = interface.isPcapDumpInterface()
local is_packet_interface = interface.isPacketInterface()
ifId = ifs.id
-- ##############################################
if active_page == "home" or active_page == "about" or active_page == "telemetry" then
print [[
]]
end
-- ##############################################
if ntop.getPrefs().are_alerts_enabled == true then
local active = ""
local style = ""
local color = ""
-- if alert_cache["num_alerts_engaged"] > 0 then
-- color = 'style="color: #B94A48;"' -- bootstrap danger red
-- end
if not ifs["has_alerts"] and not alerts_api.hasEntitiesWithAlertsDisabled(ifId) then
style = ' style="display: none;"'
end
if active_page == "alerts" then
active = ' active'
end
-- local color = "#F0AD4E" -- bootstrap warning orange
print [[
')
end
-- ##############################################
if not ifs.isViewed then -- Currently, hosts are not kept for viewed interfaces, only for their view
if active_page == "hosts" then
print [[
")
end -- closes not ifs.isViewed
-- Exporters
local info = ntop.getInfo()
if((ifs["type"] == "zmq") and ntop.isEnterprise()) then
if active_page == "exporters" then
print [[
]]
local views = {}
local drops = {}
local recording = {}
local packetinterfaces = {}
local ifnames = {}
local ifdescr = {}
local ifHdescr = {}
local ifCustom = {}
for v,k in pairs(iface_names) do
interface.select(k)
local _ifstats = interface.getStats()
ifnames[_ifstats.id] = k
ifdescr[_ifstats.id] = _ifstats.description
--io.write("["..k.."/"..v.."][".._ifstats.id.."] "..ifnames[_ifstats.id].."=".._ifstats.id.."\n")
if(_ifstats.isView == true) then views[k] = true end
if(recording_utils.isEnabled(_ifstats.id)) then recording[k] = true end
if(interface.isPacketInterface()) then packetinterfaces[k] = true end
if(_ifstats.stats_since_reset.drops * 100 > _ifstats.stats_since_reset.packets) then
drops[k] = true
end
ifHdescr[_ifstats.id] = getHumanReadableInterfaceName(_ifstats.description.."")
ifCustom[_ifstats.id] = _ifstats.customIftype
end
-- First round: only physical interfaces
-- Second round: only virtual interfaces
for round = 1, 2 do
for k,_ in pairsByValues(ifHdescr, asc) do
local descr
if((round == 1) and (ifCustom[k] ~= nil)) then
-- do nothing
elseif((round == 2) and (ifCustom[k] == nil)) then
-- do nothing
else
v = ifnames[k]
print("
]]
end -- num_ifaces > 0
if isAllowedSystemInterface() then
local system_scripts = require("system_scripts_utils")
if active_page == "system_stats" then
print [[
')
end
local lbd_serialize_by_mac = (_POST["lbd_hosts_as_macs"] == "1") or (ntop.getPref(string.format("ntopng.prefs.ifid_%u.serialize_local_broadcast_hosts_as_macs", ifs.id)) == "1")
if(ifs.has_seen_dhcp_addresses and is_admin and (not is_pcap_dump) and is_packet_interface) then
if(not lbd_serialize_by_mac) then
if(ntop.getPref(string.format("ntopng.prefs.ifid_%u.disable_host_identifier_message", ifs.id)) ~= "1") then
print('
')
end
elseif isEmptyString(_POST["dhcp_ranges"]) then
local dhcp_utils = require("dhcp_utils")
local ranges = dhcp_utils.listRanges(ifs.id)
if(table.empty(ranges)) then
print('
')
end
end
end
if ts_utils.getDriverName() == "influxdb" then
local msg = ntop.getCache("ntopng.cache.influxdb.last_error")
if not isEmptyString(msg) then
print('
')
print(msg)
print('
')
end
end
-- Hidden by default, will be shown by the footer if necessary
print('