--
-- (C) 2013-21 - 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
local top_sites_update
local snmp_utils
if ntop.isPro() then
package.path = dirs.installdir .. "/scripts/lua/pro/modules/?.lua;" .. package.path
package.path = dirs.installdir .. "/pro/scripts/callbacks/?.lua;" .. package.path
snmp_utils = require "snmp_utils"
top_sites_update = require("host_sites_update")
end
local json = require "dkjson"
local template = require "template_utils"
local os_utils = require "os_utils"
local format_utils = require "format_utils"
local top_talkers_utils = require "top_talkers_utils"
local internals_utils = require "internals_utils"
local page_utils = require("page_utils")
local ui_utils = require("ui_utils")
local interface_pools = require ("interface_pools")
local auth = require "auth"
local behavior_utils = require("behavior_utils")
require "lua_utils"
require "prefs_utils"
local graph_utils = require "graph_utils"
local alert_utils = require "alert_utils"
require "db_utils"
local recording_utils = require "recording_utils"
local companion_interface_utils = require "companion_interface_utils"
local storage_utils = require "storage_utils"
local have_nedge = ntop.isnEdge()
local sites_granularities = nil
local show_zmq_encryption_public_key = false
if ntop.isPro() then
shaper_utils = require("shaper_utils")
end
sendHTTPContentTypeHeader('text/html')
page = _GET["page"]
ifid = _GET["ifid"]
-- parse interface names and possibly fall back to the selected interface:
-- priority goes to the interface id
if ifid ~= nil and ifid ~= "" then
if_name = getInterfaceName(ifid)
else
-- fall-back to the default interface
if_name = ifname
ifid = interface.name2id(ifname)
end
interface.select(ifname)
ifname_clean = "iface_"..tostring(ifid)
msg = ""
local is_packet_interface = interface.isPacketInterface()
local is_pcap_dump = interface.isPcapDumpInterface()
local ifstats = interface.getStats()
if page == "syslog_producers" and not ifstats.isSyslog then
page = "overview"
end
local is_mirrored_traffic = false
local is_mirrored_traffic_pref = string.format("ntopng.prefs.ifid_%d.is_traffic_mirrored", interface.getId())
if not ntop.isnEdge() and is_packet_interface then
is_mirrored_traffic = ternary(ntop.getPref(is_mirrored_traffic_pref) == '1', true, false)
end
local service_map_available = false
local periodicity_map_available = false
service_map_available, periodicity_map_available = behavior_utils.mapsAvailable()
local disaggregation_criterion_key = "ntopng.prefs.dynamic_sub_interfaces.ifid_"..tostring(ifid)..".mode"
local charts_available = areInterfaceTimeseriesEnabled(ifid)
function inline_input_form(name, placeholder, tooltip, value, can_edit, input_opts, input_class, measure_unit)
if(can_edit) then
print(']]
if (measure_unit) then
print([[]].. i18n(measure_unit) ..[[]])
end
else
if(value ~= nil) then print(value) end
end
end
function inline_select_form(name, keys, values, curval)
print[[]]
end
-- this is a user-browseable page, so we must return counters from
-- the latest reset as the user may have chosen to reset statistics at some point
if ifstats.stats and ifstats.stats_since_reset then
-- override stats with the values calculated from the latest user reset
for k, v in pairs(ifstats.stats_since_reset) do
ifstats.stats[k] = v
end
end
if ifstats.zmqRecvStats and ifstats.zmqRecvStats_since_reset then
-- override stats with the values calculated from the latest user reset
for k, v in pairs(ifstats.zmqRecvStats_since_reset) do
ifstats.zmqRecvStats[k] = v
end
end
local ext_interfaces = {}
-- refresh traffic recording availability as one may have installed n2disk
-- with a running instance of ntopng
recording_utils.checkAvailable()
if recording_utils.isAvailable() and recording_utils.isSupportedZMQInterface(ifid) then
ext_interfaces = recording_utils.getExtInterfaces(ifid)
end
if (isAdministrator()) then
if (page == "config") and (not table.empty(_POST)) then
local custom_name = _POST["custom_name"]
if starts(custom_name, "tcp:__") then
-- Was mangled by sanitization
custom_name = "tcp://" .. string.sub(custom_name, 7)
end
ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.name', custom_name)
local ifspeed_cache = 'ntopng.prefs.ifid_'..ifstats.id..'.speed'
if isEmptyString(_POST["ifSpeed"]) then
ntop.delCache(ifspeed_cache)
else
ntop.setCache(ifspeed_cache, _POST["ifSpeed"])
end
local hide_set = getHideFromTopSet(ifstats.id)
ntop.delCache(hide_set)
for _, net in pairs(split(_POST["hide_from_top"] or "", ",")) do
net = trimSpace(net)
if not isEmptyString(net) then
local address, prefix, vlan = splitNetworkWithVLANPrefix(net)
if isIPv6(address) and prefix == "128" then
net = address
elseif isIPv4(address) and prefix == "32" then
net = address
end
ntop.setMembersCache(hide_set, net)
end
end
interface.reloadHideFromTop()
if is_packet_interface then
if _POST["gw_macs"] ~= nil then
-- Gw MAC addresses - used to compute traffic direction
local gw_macs_set = getGwMacsSet(ifstats.id)
ntop.delCache(gw_macs_set)
for _, mac in pairs(split(_POST["gw_macs"] or "", ",")) do
mac = trimSpace(mac)
if not isEmptyString(mac) then
ntop.setMembersCache(gw_macs_set, mac)
end
end
interface.reloadGwMacs()
end
end
if not ntop.isnEdge() and is_packet_interface then
if _POST["is_mirrored_traffic"] == "1" then
is_mirrored_traffic = true
else
is_mirrored_traffic = false
end
ntop.setPref(is_mirrored_traffic_pref, ternary(is_mirrored_traffic == true, '1', '0'))
interface.updateTrafficMirrored()
end
setInterfaceRegreshRate(ifstats.id, tonumber(_POST["ifRate"]))
local sf = tonumber(_POST["scaling_factor"])
if(sf == nil) then sf = 1 end
ntop.setCache("ntopng.prefs.iface_" .. tostring(ifid)..'.scaling_factor',tostring(sf))
interface.loadScalingFactorPrefs()
end
end
page_utils.set_active_menu_entry(page_utils.menu_entries.interface, { ifname=getHumanReadableInterfaceName(if_name) })
print("")
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
print(msg)
if _SERVER["REQUEST_METHOD"] == "POST" and _POST["companion_interface"] ~= nil then
companion_interface_utils.setCompanion(ifstats.id, _POST["companion_interface"])
end
if _SERVER["REQUEST_METHOD"] == "POST" and _POST["disaggregation_criterion"] ~= nil then
if _POST["disaggregation_criterion"] == "none" then
ntop.delCache(disaggregation_criterion_key)
else
ntop.setCache(disaggregation_criterion_key, _POST["disaggregation_criterion"])
end
end
if _SERVER["REQUEST_METHOD"] == "POST" and not isEmptyString(_POST["traffic_recording_provider"]) then
local prev_provider = recording_utils.getCurrentTrafficRecordingProvider(ifstats.id)
-- if the current provider is the builtin ntopng and we are changing to another provider
-- then it may be necessary to stop the builtin ntopng
if prev_provider == "ntopng" and _POST["traffic_recording_provider"] ~= "ntopng" then
recording_utils.stop(ifstats.id)
ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled', "false")
end
recording_utils.setCurrentTrafficRecordingProvider(ifstats.id, _POST["traffic_recording_provider"])
end
local has_traffic_recording_page = (recording_utils.isAvailable()
and (is_packet_interface
or ((recording_utils.isSupportedZMQInterface(ifid) and not table.empty(ext_interfaces)))
or (recording_utils.getCurrentTrafficRecordingProvider(ifid) ~= "ntopng")))
local dismiss_recording_providers_reminder = recording_utils.isExternalProvidersReminderDismissed(ifstats.id)
local url = ntop.getHttpPrefix()..'/lua/if_stats.lua?ifid=' .. ifid
-- Added global javascript variable, in order to disable the refresh of pie chart in case
-- of historical interface
print('\n\n')
local short_name = getHumanReadableInterfaceName(ifname)
local title = i18n("interface") .. ": " .. shortenCollapse(short_name)
if (ntop.isPro()) then
sites_granularities = top_sites_update.getGranularitySites(nil, nil, ifId, true)
end
page_utils.print_navbar(title, url,
{
{
hidden = only_historical,
active = page == "overview" or page == nil,
page_name = "overview",
label = "",
},
{
hidden = not is_packet_interface or ntop.isnEdge() or interface.isView(),
active = page == "networks",
page_name = "networks",
label = i18n("networks"),
},
{
hidden = have_nedge or not ifstats or ifstats.stats.packets == 0 or ntop.isnEdge(),
active = page == "packets",
page_name = "packets",
label = i18n("packets"),
},
{
hidden = not ifstats or not ifstats["has_macs"] or ntop.isnEdge(),
active = page == "DSCP",
page_name = "DSCP",
label = i18n("dscp"),
},
{
active = page == "ndpi",
page_name = "ndpi",
label = i18n("applications"),
},
{
hidden = have_nedge,
active = page == "ICMP",
page_name = "ICMP",
label = i18n("icmp"),
},
{
hidden = not ifstats or not ifstats["has_macs"] or ntop.isnEdge(),
active = page == "ARP",
page_name = "ARP",
label = i18n("arp"),
},
{
hidden = (table.len(sites_granularities) == 0),
active = page == "sites",
page_name = "sites",
label = i18n("sites_page.sites"),
},
{
hidden = not charts_available,
active = page == "historical",
page_name = "historical",
label = "",
},
{
hidden = have_nedge or not ifstats or table.empty(ifstats.profiles),
active = page == "trafficprofiles",
page_name = "trafficprofiles",
label = "",
},
{
hidden = not has_traffic_recording_page,
active = page == "traffic_recording",
page_name = "traffic_recording",
label = "",
},
{
hidden = not areAlertsEnabled() or not auth.has_capability(auth.capabilities.alerts),
active = page == "alerts",
page_name = "alerts",
url = ntop.getHttpPrefix() .. "/lua/alert_stats.lua?&page=interface",
label = "",
},
{
hidden = not hasTrafficReport(),
active = page == "traffic_report",
page_name = "traffic_report",
label = "",
},
{
hidden = not isAdministrator() or is_pcap_dump,
active = page == "config",
page_name = "config",
label = "",
},
{
active = page == "internals",
page_name = "internals",
label = "",
},
{
hidden = have_nedge or not isAdministrator() or not ntop.isEnterpriseM() or ifstats.isDynamic or ifstats.isView,
active = page == "sub_interfaces",
page_name = "sub_interfaces",
label = "",
},
{
hidden = have_nedge or not isAdministrator() or not ifstats.isSyslog,
active = page == "syslog_producers",
page_name = "syslog_producers",
label = "",
},
{
hidden = not isAdministrator() or not ifstats.has_macs or have_nedge,
active = page == "unassigned_pool_devices",
page_name = "unassigned_pool_devices",
label = "",
},
{
hidden = not isAdministrator() or is_pcap_dump,
active = page == "dhcp",
page_name = "dhcp",
label = "",
},
{
hidden = (not periodicity_map_available),
page_name = "periodicity_map",
url = ntop.getHttpPrefix() .. "/lua/pro/enterprise/periodicity_map.lua",
label = "",
},
{
hidden = (not service_map_available),
page_name = "service_map",
url = ntop.getHttpPrefix() .. "/lua/pro/enterprise/service_map.lua",
label = "",
},
}
)
print(
template.gen("modal_confirm_dialog.html", {
dialog={
id = "reset_stats_dialog",
action = "resetCounters(false)",
title = i18n("reset_if_title"),
message = i18n("reset_if_message"),
confirm = i18n("reset"),
confirm_button = "btn-danger",
}
})
)
print(
template.gen("modal_confirm_dialog.html", {
dialog={
id = "reset_drops_dialog",
action = "resetCounters(true)",
title = i18n("reset_drops_if_title"),
message = i18n("reset_drops_if_message"),
confirm = i18n("reset"),
confirm_button = "btn-danger",
}
})
)
if((page == "overview") or (page == nil)) then
local tags = {ifid = ifstats.id}
print("
")
print("
\n")
print("
"..i18n("if_stats_overview.id").."
" .. ifstats.id .. " ")
if(ifstats.description ~= ifstats.name) then print(" ("..ifstats.description..")") end
print("
\n")
if not is_pcap_dump and ifstats["type"] ~= "netfilter" then
print("
"..i18n("if_stats_overview.state").."
")
state = toggleTableButton("", "", i18n("if_stats_overview.active"), "1","primary", i18n("if_stats_overview.paused"), "0","primary", "toggle_local", "ntopng.prefs.ifid_"..tostring(ifid).."_not_idle")
if(state == "0") then
on_state = true
else
on_state = false
end
interface.setInterfaceIdleState(on_state)
print("
\n")
end
if(ifstats.probes ~= nil) then
local max_items_per_row = 3
local cur_i = 0
local title = i18n("if_stats_overview.remote_probe")
if ifstats["remote.name"] == "none" then
title = title .. " [" .. i18n("if_stats_overview.remote_probe_collector_mode") .. "]"
end
print("
".. title .."
")
if(ifstats["remote.name"] ~= "none") then
print("
')
cur_i = cur_i + 1
end
-- #########################
if ifstats["timeout.lifetime"] and ifstats["timeout.lifetime"] > 0 then
if cur_i >= max_items_per_row then print("
")
if((ifstats["timeout.collected_lifetime"] ~= nil) and (ifstats["timeout.collected_lifetime"] > 0)) then
-- We're in collector mode on the nProbe side
print(" "..secondsToTime(ifstats["timeout.lifetime"]).." [".. i18n("if_stats_overview.remote_flow_lifetime")..": "..secondsToTime(ifstats["timeout.collected_lifetime"]).."]")
else
-- Modern nProbe in non-flow collector mode or old nProbe
print(secondsToTime(ifstats["timeout.lifetime"]))
end
print("
")
cur_i = cur_i + 1
end
if ifstats["timeout.idle"] and ifstats["timeout.idle"] > 0 then
if cur_i >= max_items_per_row then print("
")
cur_i = cur_i + 1
end
if not isEmptyString(ifstats["probe.local_time"]) and not isEmptyString(ifstats["probe.remote_time"]) then
local tdiff = math.abs(ifstats["probe.local_time"]-ifstats["probe.remote_time"])
if cur_i >= max_items_per_row then print("
")
if(tdiff > 10) then print("") end
print(formatValue(tdiff).." sec")
if(tdiff > 10) then print("") end
print("
")
cur_i = cur_i + 1
end
local has_drops_export_queue_full = (tonumber(ifstats["zmq.drops.export_queue_full"]) and tonumber(ifstats["zmq.drops.export_queue_full"]) > 0)
local has_drops_flow_collection_drops = (tonumber(ifstats["zmq.drops.flow_collection_drops"]) or 0) > 0
local has_drops_flow_collection_udp_socket_drops = (tonumber(ifstats["zmq.drops.flow_collection_udp_socket_drops"]) or 0) > 0
local has_remote_drops = (has_drops_export_queue_full or has_drops_flow_collection_drops)
if has_drops_export_queue_full then
local span_class = ' '
if cur_i >= max_items_per_row then print("
")
end
local is_physical_iface = is_packet_interface and (not is_pcap_dump)
local label = getHumanReadableInterfaceName(ifstats.name)
local s
if ((not isEmptyString(label)) and (label ~= ifstats.name)) then
s = label.." (" .. ifstats.name .. ")"
else
s = ifstats.name
end
if((isAdministrator()) and (not is_pcap_dump)) then
s = s .. " "
end
print('
'..i18n("name")..'
')
print(s)
if(ifstats.mac and ifstats.mac ~= "00:00:00:00:00:00") then print(" [" .. ifstats.mac .. "]"); end
print('
\n')
print("
"..i18n("if_stats_overview.family").."
")
if(ifstats.type == "zmq") then
print("ZMQ")
else
print(ifstats.type)
end
if(ifstats.inline) then
print(" "..i18n("if_stats_overview.in_path_interface"))
end
if(ifstats.has_traffic_directions) then
print(" ".. i18n("if_stats_overview.has_traffic_directions") .. " ")
end
print("
")
show_zmq_encryption_public_key = (ifstats.encryption and ifstats.encryption.public_key and isAdministrator())
if show_zmq_encryption_public_key == true then
print("
\n")
end
if is_physical_iface and not ifstats.isView then
print("
")
print("
"..i18n("mtu").."
"..ifstats.mtu.." "..i18n("bytes").."
\n")
local speed_key = 'ntopng.prefs.ifid_'..tostring(interface.name2id(ifname))..'.speed'
local speed = ntop.getCache(speed_key)
if (tonumber(speed) == nil) then
speed = ifstats.speed
end
print("
"..i18n("speed").."
" .. bitsToSize(speed * 1000000) .. "
")
print("
")
end
if (not hasAllowedNetworksSet()) and ((ifstats.num_alerts_engaged > 0) or (ifstats.num_dropped_alerts > 0)) then
print("
")
-- Additional stats (e.g. Suricata)
local external_json_stats = ntop.getCache("ntopng.prefs.ifid_"..tostring(ifid)..".external_stats")
if not isEmptyString(external_json_stats) then
local external_stats = json.decode(external_json_stats)
if external_stats ~= nil then
local external_stats_title = i18n("external_stats.title")
if external_stats.i18n_title then
external_stats_title = i18n(external_stats.i18n_title)
external_stats.i18n_title = nil
end
print("
"..external_stats_title.."
\n")
for key, value in pairsByKeys(external_stats, asc) do
print("
")
end
end
end
end
if prefs.is_dump_flows_enabled and not ifstats.isViewed then
local dump_to = "MySQL"
if prefs.is_dump_flows_to_es_enabled == true then
dump_to = "ElasticSearch"
end
if prefs.is_dump_flows_to_syslog_enabled == true then
dump_to = "Syslog"
end
if prefs.is_nindex_enabled == true then
dump_to = "nIndex"
end
local export_count = ifstats.stats.flow_export_count
local export_rate = ifstats.stats.flow_export_rate
local export_drops = ifstats.stats.flow_export_drops
local export_drops_pct = 0
if not export_drops or not export_count then
-- Nothing to do
elseif export_drops > 0 and export_count > 0 then
export_drops_pct = export_drops / (export_count + export_drops) * 100
elseif export_drops > 0 then
export_drops_pct = 100
end
print("
")
if prefs.is_dump_flows_runtime_enabled then
print(dump_to.." "..i18n("if_stats_overview.flows_export_statistics"))
else
print(i18n("if_stats_overview.export_disabled"))
end
print("
\n")
end
local an = ifstats.anomalies.tot_num_anomalies or {}
local tot_an = 0
if table.len(an) > 0 then
tot_an = an.local_hosts + an.remote_hosts
end
if(tot_an > 0) then
-- TODO: Add JSON update
print("
\n") -- Cell for future usage
end
if isAdministrator() and ifstats.isView == false then
local ts_utils = require "ts_utils_core"
local storage_info = storage_utils.interfaceStorageInfo(ifid)
local storage_items = {}
if storage_info then
if ts_utils.getDriverName() == "rrd" then
if storage_info.rrd ~= nil and storage_info.rrd > 0 then
table.insert(storage_items, {
title = i18n("if_stats_overview.rrd_timeseries"),
value = storage_info.rrd,
class = "primary",
})
end
end
if storage_info.flows ~= nil and storage_info.flows > 0 then
table.insert(storage_items, {
title = i18n("flows"),
value = storage_info.flows,
class = "info",
})
end
if storage_info.pcap ~= nil and storage_info.pcap > 0 then
local link = nil
if recording_utils.isAvailable(ifstats.id) then
link = ntop.getHttpPrefix() .. "/lua/if_stats.lua?ifid=" .. ifid .. "&page=traffic_recording"
end
table.insert(storage_items, {
title = i18n("traffic_recording.packet_dumps"),
value = storage_info.pcap,
class = "warning",
link = link
})
end
if #storage_items > 0 then
print("
\n")
end
end
end
if ntop.isPcapDownloadAllowed() and ifstats.isView == false and ifstats.isDynamic == false and is_packet_interface then
print("
"..i18n("download").."
")
local live_traffic_utils = require("live_traffic_utils")
live_traffic_utils.printLiveTrafficForm(interface.getId())
print("
\n")
end
if isAdministrator() then
print("
"..i18n("if_stats_overview.reset_counters").."
")
print("
")
local tot = ifstats.stats.bytes + ifstats.stats.packets + ifstats.stats.drops
if(ifstats.stats.flow_export_count ~= nil) then
tot = tot + ifstats.stats.flow_export_count + ifstats.stats.flow_export_drops
end
print(' ')
print('')
print("
")
print("
\n")
end
if have_nedge and ifstats.type == "netfilter" and ifstats.netfilter then
local st = ifstats.netfilter
print("
"..i18n("if_stats_overview.nf_queue_total").."
")
local span_class = ''
if st.nfq.queue_pct > 80 then
span_class = "class='badge bg-danger'"
end
print("
") -- close of table responsive
elseif page == "networks" and is_packet_interface then
print("
")
if(ifstats.ip_addresses ~= "") then
local tokens = split(ifstats.ip_addresses, ",")
if(tokens ~= nil) then
print("
"..i18n("ip_address").."
")
local addresses = {}
for _,s in pairs(tokens) do
t = string.split(s, "/")
host = interface.getHostInfo(t[1])
if(host ~= nil) then
addresses[#addresses+1] = hostinfo2detailshref(host, nil, t[1]).."/"..t[2]
else
addresses[#addresses+1] = s
end
end
print(table.concat(addresses, "\n
")
end
local has_ghost_networks = false
local ghost_icon = ''
if ifstats.bcast_domains and table.len(ifstats.bcast_domains) > 0 then
print("
"..i18n("broadcast_domain").."
")
local bcast_domains = {}
for bcast_domain, domain_info in pairsByKeys(ifstats.bcast_domains) do
bcast_domain = string.format("%s", ntop.getHttpPrefix(), bcast_domain, bcast_domain)
if domain_info.ghost_network then
has_ghost_networks = true
bcast_domain = bcast_domain..' '..ghost_icon
end
bcast_domains[#bcast_domains + 1] = bcast_domain
end
if #bcast_domains > 0 then
print("
")
for _, bcast_domain in ipairs(bcast_domains) do
print("
\n")
for pname,pbytes in pairs(ifstats.profiles) do
local trimmed = trimSpace(pname)
local statschart_icon = ''
if areInterfaceTimeseriesEnabled(ifid) then
statschart_icon = ''
end
print("
"..pname.."
"..statschart_icon.."
"..bytesToSize(pbytes).."
\n")
end
print [[
]]
elseif(page == "traffic_recording" and has_traffic_recording_page) then
if not dismiss_recording_providers_reminder then
print('
')
print [[
]]
end
local tab = _GET["tab"] or "config"
local recording_enabled = recording_utils.isEnabled(ifstats.id)
-- config tab is only shown when the recording service is managed by ntopng
-- otherwise it is assumed that the user is managing the service manually with n2disk
local config_enabled = (recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) == "ntopng")
if tab == "config" and not config_enabled then
if recording_enabled then tab = "status" else tab = "" end
end
if (tab == "status" or tab == "jobs") and not recording_enabled then
if config_enabled then tab = "config" else tab = "" end
end
if(_SERVER["REQUEST_METHOD"] == "POST") and (tab == "config") then
recording_enabled = not isEmptyString(_POST["record_traffic"])
end
print('
')
if recording_enabled and tab == "status" then
dofile(dirs.installdir .. "/scripts/lua/inc/traffic_recording_status.lua")
elseif recording_enabled and ntop.isEnterpriseM() and tab == "jobs" then
dofile(dirs.installdir .. "/scripts/lua/inc/traffic_recording_jobs.lua")
elseif config_enabled and tab == "config" then -- config, default
dofile(dirs.installdir .. "/scripts/lua/inc/traffic_recording_config.lua")
end
print('
')
elseif(page == "config") then
if(not isAdministrator()) then
return
end
local interface_pools_instance = interface_pools:create()
local messages = {}
-- Flow dump check
local interface_flow_dump = true
if prefs.is_dump_flows_enabled then
interface_flow_dump = (ntop.getPref("ntopng.prefs.ifid_"..interface.getId()..".is_flow_dump_disabled") ~= "1")
if _SERVER["REQUEST_METHOD"] == "POST" then
local new_value = (_POST["interface_flow_dump"] == "1")
if new_value ~= interface_flow_dump then
-- Value changed
interface_flow_dump = new_value
ntop.setPref("ntopng.prefs.ifid_"..interface.getId()..".is_flow_dump_disabled", ternary(interface_flow_dump, "0", "1"))
messages[#messages + 1] = {
type = "warning",
text = i18n("prefs.restart_needed", {product=info.product}),
}
end
end
end
if _SERVER["REQUEST_METHOD"] == "POST" then
-- bind interface to pool
if (_POST["pool"]) then
interface_pools_instance:bind_member(ifid, tonumber(_POST["pool"]))
end
end
if not table.empty(messages) then
printMessageBanners(messages)
print(" ")
end
print[[
]]
elseif(page == "internals") then
internals_utils.printInternals(ifid, true --[[ hash tables ]], true --[[ periodic activities ]], true --[[ checks]], true --[[ queues --]])
print [[
]]
elseif(page == "snmp_bind") then
if ((not hasSnmpDevices(ifstats.id)) or (not is_packet_interface)) then
return
end
local snmp_host = _POST["ip"]
local snmp_interface = _POST["snmp_port_idx"] or ""
if (snmp_host ~= nil) then
-- snmp_host can be empty
snmp_utils.set_snmp_bound_interface(ifstats.id, snmp_host, snmp_interface)
else
local value = snmp_utils.get_snmp_bound_interface(ifstats.id)
if value ~= nil then
snmp_host = value.snmp_device
snmp_interface = value.snmp_port
end
end
local snmp_devices = snmp_utils.get_snmp_devices(ifstats.id)
print[[
]] print(i18n("snmp.note") .. ":") print[[
]] print(i18n("snmp.bound_interface_description")) print[[
]]
elseif(page == "sub_interfaces") then
if(isAdministrator() and ntop.isEnterpriseM()) then
dofile(dirs.installdir .. "/pro/scripts/lua/enterprise/sub_interfaces.lua")
end
elseif(page == "syslog_producers") then
if(isAdministrator()) then
dofile(dirs.installdir .. "/scripts/lua/syslog_producers.lua")
end
elseif(page == "unassigned_pool_devices") then
dofile(dirs.installdir .. "/scripts/lua/unknown_devices.lua")
elseif(page == "dhcp") then
dofile(dirs.installdir .. "/scripts/lua/admin/dhcp.lua")
elseif page == "traffic_report" then
package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/?.lua;" .. package.path
local traffic_report = require "traffic_report"
traffic_report.generate_traffic_report()
end
print("
]]
print [[
]]
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
if show_zmq_encryption_public_key == true then
print[[
]]
end
print[[
]]