-- -- (C) 2013-18 - ntop.org -- 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 active_page = "if_stats" 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 require "snmp_utils" end local json = require "dkjson" local host_pools_utils = require "host_pools_utils" local template = require "template_utils" local os_utils = require "os_utils" local format_utils = require "format_utils" local page_utils = require("page_utils") require "lua_utils" require "prefs_utils" require "graph_utils" require "alert_utils" require "db_utils" local ts_utils = require "ts_utils" local recording_utils = require "recording_utils" local storage_utils = require "storage_utils" local have_nedge = ntop.isnEdge() if ntop.isPro() then shaper_utils = require("shaper_utils") end sendHTTPContentTypeHeader('text/html') page = _GET["page"] ifid = _GET["ifid"] ifname_clean = "iface_"..tostring(ifid) msg = "" function inline_input_form(name, placeholder, tooltip, value, can_edit, input_opts, input_class) if(can_edit) then print(']] else if(value ~= nil) then print(value) end end end if(_POST["switch_interface"] ~= nil) then -- First switch interfaces so the new cookie will have effect ifname = interface.setActiveInterfaceId(tonumber(ifid)) --print("@"..ifname.."="..id.."@") if((ifname ~= nil) and (_SESSION["session"] ~= nil)) then key = getRedisPrefix("ntopng.prefs") .. ".ifname" ntop.setCache(key, ifname) msg = "
" .. i18n("if_stats_overview.iface_switch_active_msg", {interface=getHumanReadableInterfaceName(ifname), ifid=ifid}) .. "
" ntop.setCache(getRedisPrefix("ntopng.prefs")..'.iface', ifid) else msg = "
" .. i18n("if_stats_overview.iface_switch_error_msg") .. "
" if(_SESSION["session"] == nil) then msg = msg .."
" .. i18n("if_stats_overview.iface_switch_empty_session_msg") .. "
" end end end -- 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) local is_packet_interface = interface.isPacketInterface() local ifstats = interface.getStats() -- 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 local ext_interfaces = {} 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 -- TODO move keys to new schema: replace ifstats.name with ifid ntop.setCache('ntopng.prefs.'..ifstats.name..'.name',_POST["custom_name"]) local ifspeed_cache = 'ntopng.prefs.'..ifstats.name..'.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 = splitNetworkPrefix(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() setInterfaceRegreshRate(ifstats.id, tonumber(_POST["ifRate"])) local sf = tonumber(_POST["scaling_factor"]) if(sf == nil) then sf = 1 end ntop.setCache(getRedisIfacePrefix(ifid)..'.scaling_factor',tostring(sf)) interface.loadScalingFactorPrefs() end end page_utils.print_header(i18n("interface_ifname", { ifname=if_name })) print("") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print(msg) 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') print [[ ]] if((page == "overview") or (page == nil)) then print("\n") print("\n") if interface.isPcapDumpInterface() == false and ifstats["type"] ~= "netfilter" then print("\n") end if(ifstats["remote.name"] ~= nil) then local remote_if_addr, remote_probe_ip, remote_probe_public_ip = '', '', '' local num_remote_flow_exports, num_remote_flow_exporters = '', '' if not isEmptyString(ifstats["remote.if_addr"]) then remote_if_addr = ""..i18n("if_stats_overview.interface_ip")..": "..ifstats["remote.if_addr"] end if not isEmptyString(ifstats["probe.ip"]) then remote_probe_ip = ""..i18n("if_stats_overview.probe_ip")..": "..ifstats["probe.ip"] end if not isEmptyString(ifstats["probe.public_ip"]) then remote_probe_public_ip = ""..i18n("if_stats_overview.public_probe_ip")..": "..ifstats["probe.public_ip"].."\n" end if not isEmptyString(ifstats["zmq.num_flow_exports"]) then num_remote_flow_exports = ""..i18n("if_stats_overview.probe_zmq_num_flow_exports")..": "..formatValue(ifstats["zmq.num_flow_exports"]).."" end if not isEmptyString(ifstats["zmq.num_exporters"]) then num_remote_flow_exporters = ""..i18n("if_stats_overview.probe_zmq_num_endpoints")..": "..formatValue(ifstats["zmq.num_exporters"]).."" end print("") print("") print("") print("\n") print("\n") print("") local colspan = 4 if ifstats["timeout.lifetime"] > 0 then print("") else colspan = colspan - 1 end if ifstats["timeout.idle"] > 0 then print("") else colspan = colspan - 1 end print("") print("") 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"]) and tonumber(ifstats["zmq.drops.flow_collection_drops"]) > 0) local has_remote_drops = (has_drops_export_queue_full or has_drops_flow_collection_drops) if not has_remote_drops then print('') else print("") local export_queue_full, flow_collection_drops local colspan = 5 if has_drops_export_queue_full then local num_full = tonumber(ifstats["zmq.drops.export_queue_full"]) local span_class = ' ' if num_full > 0 then span_class = 'class="label label-danger"' end export_queue_full = ""..i18n("if_stats_overview.probe_zmq_drops_export_queue_full").." : "..formatValue(ifstats["zmq.drops.export_queue_full"]).."" end if has_drops_flow_collection_drops then local num_full = tonumber(ifstats["zmq.drops.flow_collection_drops"]) local span_class = ' ' if num_full > 0 then span_class = 'class="label label-danger"' end flow_collection_drops = ""..i18n("if_stats_overview.probe_zmq_drops_flow_collection_drops").." : "..formatValue(ifstats["zmq.drops.flow_collection_drops"]).."" end if export_queue_full then print("") colspan = colspan - 1 end if flow_collection_drops then print("") colspan = colspan - 1 end if colspan then print("") end end print("") end local is_physical_iface = (interface.isPacketInterface()) and (interface.isPcapDumpInterface() == false) local is_bridge_iface = (ifstats["bridge.device_a"] ~= nil) and (ifstats["bridge.device_b"] ~= nil) if not is_bridge_iface then 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 (interface.isPcapDumpInterface() == false)) then s = s .. " " end print('\n') else print("") end print("") if not is_bridge_iface then if(ifstats.ip_addresses ~= "") then tokens = split(ifstats.ip_addresses, ",") end if(tokens ~= nil) then print("") end end if is_physical_iface then print("") print("\n") if (not is_bridge_iface) then local speed_key = 'ntopng.prefs.'..ifname..'.speed' local speed = ntop.getCache(speed_key) if (tonumber(speed) == nil) then speed = ifstats.speed end print("") else print("") end print("") end label = i18n("pkts") print[[ ]] if(ifstats.type ~= "zmq") then print [[ ]] else print [[ ]] end print [[ \n") if(ifstats.zmqRecvStats ~= nil) then print("\n") print("") print("") print("") print("") -- empty placeholder, can be used for future items print("") end print("\n") print("") if ifstats.isDynamic == false then print("") print("") else print("") end print("") if(ifstats.has_traffic_directions) then print("") print("") end if(prefs.is_dump_flows_enabled and ifstats.isView == false) 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_ls_enabled == true then dump_to = "Logstash" 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 export_drops == nill then elseif export_drops > 0 and export_count > 0 then export_drops_pct = export_drops / export_count * 100 elseif export_drops > 0 then export_drops_pct = 100 end print("\n") print("") print("") print("") print("") local span_danger = "" if export_drops == nil then elseif(export_drops > 0) then span_danger = ' class="label label-danger"' end print("") print("") print("") end if isAdministrator() and ifstats.isView == false then local storage_info = storage_utils.interfaceStorageInfo(ifid) local storage_items = {} if storage_info.rrd ~= nil and storage_info.rrd > 0 then table.insert(storage_items, { title = i18n("prefs.timeseries"), value = storage_info.rrd, class = "primary", }) 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 if (isAdministrator() and ifstats.isView == false and ifstats.isDynamic == false and interface.isPacketInterface()) then print("\n") print("") print("") print("\n") end if have_nedge and ifstats.type == "netfilter" and ifstats.netfilter then local st = ifstats.netfilter print("") local span_class = '' if st.nfq.queue_pct > 80 then span_class = "class='label label-danger'" end print("") print("") print("") print("") print("") print("") print("") print("") end print [[ ]] print("
"..i18n("if_stats_overview.id").."" .. ifstats.id .. " ") if(ifstats.description ~= ifstats.name) then print(" ("..ifstats.description..")") end 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."..if_name.."_not_idle") if(state == "0") then on_state = true else on_state = false end interface.setInterfaceIdleState(on_state) print("
"..i18n("if_stats_overview.remote_probe")..""..i18n("if_stats_overview.interface_name")..": "..ifstats["remote.name"].." [ ".. maxRateToString(ifstats.speed*1000) .." ]"..remote_if_addr..""..remote_probe_ip..""..remote_probe_public_ip.."
"..i18n("if_stats_overview.probe_timeout_lifetime")..": "..secondsToTime(ifstats["timeout.lifetime"])..""..i18n("if_stats_overview.probe_timeout_idle")..": "..secondsToTime(ifstats["timeout.idle"])..""..num_remote_flow_exporters.."
"..export_queue_full..""..flow_collection_drops.."
'..i18n("name")..'' .. s ..'
"..i18n("bridge")..""..ifstats["bridge.device_a"].." "..ifstats["bridge.device_b"]) print(""..i18n("if_stats_overview.family").."") print(ifstats.type) 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("
"..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] = "".. t[1].."" else addresses[#addresses+1] = t[1] end end print(table.concat(addresses, ", ")) print("
"..i18n("mtu")..""..ifstats.mtu.." "..i18n("bytes")..""..i18n("speed").."" .. maxRateToString(speed*1000) .. "
]] print(i18n("if_stats_overview.traffic_breakdown")) print[[
"..i18n("if_stats_overview.zmq_rx_statistics").."
"..i18n("if_stats_overview.collected_flows")..""..formatValue(ifstats.zmqRecvStats.flows)..""..i18n("if_stats_overview.interface_rx_updates")..""..formatValue(ifstats.zmqRecvStats.events)..""..i18n("if_stats_overview.sflow_counter_updates")..""..formatValue(ifstats.zmqRecvStats.counters).."
"..i18n("if_stats_overview.zmq_message_drops")..""..formatValue(ifstats.zmqRecvStats.zmq_msg_drops).."
"..i18n("if_stats_overview.traffic_statistics").."
"..i18n("report.total_traffic")..""..bytesToSize(ifstats.stats.bytes).." [".. formatValue(ifstats.stats.packets) .. " ".. label .."] ") print(" ") print(i18n("if_stats_overview.dropped_packets").."") if(ifstats.stats.drops > 0) then print('') end print(formatValue(ifstats.stats.drops).. " " .. label) if((ifstats.stats.packets+ifstats.stats.drops) > 0) then local pctg = round((ifstats.stats.drops*100)/(ifstats.stats.packets+ifstats.stats.drops), 2) if(pctg > 0) then print(" [ " .. pctg .. " % ] ") end end if(ifstats.stats.drops > 0) then print('') end print(" ") if(ifstats.zmqRecvStats ~= nil) then print("

"..i18n("if_stats_overview.note")..":
".. i18n("if_stats_overview.note_drops_sflow").."
") end print("

") print(""..i18n("if_stats_overview.note")..": "..i18n("if_stats_overview.note_drop_ifstats_dynamic").."") print("
"..i18n("http_page.traffic_sent")..""..bytesToSize(ifstats.eth.egress.bytes).." [".. formatValue(ifstats.eth.egress.packets) .. " ".. label .."] "..i18n("http_page.traffic_received")..""..bytesToSize(ifstats.eth.ingress.bytes).." [".. formatValue(ifstats.eth.ingress.packets) .. " ".. label .."]
"..dump_to.." "..i18n("if_stats_overview.flows_export_statistics").."
"..i18n("if_stats_overview.exported_flows")..""..formatValue(export_count).."") if export_rate == nil then export_rate = 0 end print(" ["..formatValue(round(export_rate, 2)).." Flows/s] ") print(i18n("if_stats_overview.dropped_flows")..""..formatValue(export_drops).." ") print("[" ..formatValue(round(export_drops_pct, 2)).."%] 
"..i18n("traffic_recording.storage_utilization").."") print(stackedProgressBars(storage_info.total, storage_items, nil, bytesToSize)) print("
"..i18n("download").." ") local live_traffic_utils = require("live_traffic_utils") live_traffic_utils.printLiveTrafficForm(ifId) print("
"..i18n("if_stats_overview.reset_counters").."") 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("
"..i18n("if_stats_overview.nf_queue_total")..""..string.format("%s [%s %%]", formatValue(st.nfq.queue_total), formatValue(st.nfq.queue_pct)).." "..i18n("if_stats_overview.nf_handle_packet_failed")..""..formatValue(st.failures.handle_packet).." "..i18n("if_stats_overview.nf_enobufs")..""..formatValue(st.failures.no_buffers).."
Conntrack Flow Entries") print(""..formatValue(st.nfq.num_conntrack_entries).."
]] print(i18n("if_stats_overview.note")..":

"..i18n("if_stats_overview.note_packets")) print[[

\n") elseif((page == "packets")) then local nedge_hidden = ternary(have_nedge, 'class="hidden"', '') print [[ ]] print("\n") print("\n") print("\n") if(ifstats.type ~= "zmq") then print [[]] end print[[
" .. i18n("packets_page.tcp_packets_analysis") .. "" .. i18n("packets_page.retransmissions") .."".. formatPackets(ifstats.tcpPacketStats.retransmissions) .."
" .. i18n("packets_page.out_of_order") .. "".. formatPackets(ifstats.tcpPacketStats.out_of_order) .."
" .. i18n("packets_page.lost") .. "".. formatPackets(ifstats.tcpPacketStats.lost) .."
]] print(i18n("packets_page.size_distribution")) print [[
]] print(i18n("packets_page.tcp_flags_distribution")) print[[
]] print(i18n("packets_page.ip_version_distribution")) print[[

]] elseif(page == "ndpi") then print[[


]] if ntop.isPro() and ifstats["custom_apps"] then print[[ ]] end print[[
]] print(i18n("ndpi_page.overview", {what = i18n("ndpi_page.custom_applications")})) print [[
]] print(i18n("ndpi_page.overview", {what = i18n("applications")})) print [[
]] print(i18n("ndpi_page.live_flows_count")) print [[

]] print(i18n("ndpi_page.note")) print [[ :]] print(i18n("ndpi_page.note_live_flows_chart")) print [[
]] print(i18n("application")) print[[ ]] print(i18n("ndpi_page.total_since_startup")) print[[ ]] print(i18n("percentage")) print[[

]] print(i18n("ndpi_page.overview", {what = i18n("categories")})) print [[
]] print(i18n("category")) print[[ ]] print(i18n("ndpi_page.total_since_startup")) print[[ ]] print(i18n("percentage")) print[[
]] print [[ ]] elseif(page == "ICMP") then print [[
]] print(i18n("icmp_page.icmp_message")) print [[]] print(i18n("packets")) print[[
]] elseif(page == "ARP") then print [[
]] print(i18n("arp_page.arp_type")) print [[]] print(i18n("packets")) print[[
]] elseif(page == "historical") then local schema = _GET["ts_schema"] or "iface:traffic" local selected_epoch = _GET["epoch"] or "" local tags = { ifid = ifid, protocol = _GET["protocol"], category = _GET["category"], } url = url.."&page=historical" drawGraphs(ifstats.id, schema, tags, _GET["zoom"], url, selected_epoch, { top_protocols = "top:iface:ndpi", top_categories = "top:iface:ndpi_categories", top_profiles = "top:profile:traffic", top_senders = "top:local_senders", top_receivers = "top:local_receivers", show_historical = true, timeseries = { {schema="iface:flows", label=i18n("graphs.active_flows")}, {schema="iface:hosts", label=i18n("graphs.active_hosts")}, {schema="custom:flows_vs_local_hosts", label=i18n("graphs.flows_vs_local_hosts"), check={"iface:flows", "iface:local_hosts"}, step=60}, {schema="custom:flows_vs_traffic", label=i18n("graphs.flows_vs_traffic"), check={"iface:flows", "iface:traffic"}, step=60}, {schema="iface:devices", label=i18n("graphs.active_devices")}, {schema="iface:http_hosts", label=i18n("graphs.active_http_servers"), nedge_exclude=1}, {schema="iface:traffic", label=i18n("traffic")}, {schema="iface:traffic_rxtx", label=i18n("graphs.traffic_txrx")}, {schema="iface:1d_delta_traffic_volume", label="1 Day Traffic Delta"}, -- TODO localize {schema="iface:1d_delta_flows", label="1 Day Active Flows Delta"}, -- TODO localize {schema="iface:packets", label=i18n("packets")}, {schema="iface:drops", label=i18n("graphs.packet_drops")}, {schema="iface:nfq_pct", label=i18n("graphs.num_nfq_pct"), nedge_only=1}, {schema="iface:zmq_recv_flows", label=i18n("graphs.zmq_received_flows"), nedge_exclude=1}, {schema="iface:zmq_flow_coll_drops", label=i18n("graphs.zmq_flow_coll_drops"), nedge_exclude=1}, {schema="iface:exported_flows", label=i18n("if_stats_overview.exported_flows"), nedge_exclude=1}, {schema="iface:dropped_flows", label=i18n("if_stats_overview.dropped_flows"), nedge_exclude=1}, {separator=1, nedge_exclude=1, label=i18n("tcp_stats")}, {schema="iface:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1}, {schema="iface:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1}, --{schema="tcp_retr_ooo_lost", label=i18n("graphs.tcp_retr_ooo_lost"), nedge_exclude=1}, {schema="iface:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1}, {separator=1, label=i18n("tcp_flags")}, {schema="iface:tcp_syn", label=i18n("graphs.tcp_syn_packets"), nedge_exclude=1}, {schema="iface:tcp_synack", label=i18n("graphs.tcp_synack_packets"), nedge_exclude=1}, {schema="iface:tcp_finack", label=i18n("graphs.tcp_finack_packets"), nedge_exclude=1}, {schema="iface:tcp_rst", label=i18n("graphs.tcp_rst_packets"), nedge_exclude=1}, } }) elseif(page == "trafficprofiles") then print("\n") print("\n") for pname,pbytes in pairs(ifstats.profiles) do local trimmed = trimSpace(pname) local statschart_icon = '' if ts_utils.exists("profile:traffic", {ifid=ifid}) then statschart_icon = '' end print("\n") end print [[
" .. i18n("traffic_profiles.profile_name") .. "" .. i18n("chart") .. "" .. i18n("traffic") .. "
"..pname..""..statschart_icon..""..bytesToSize(pbytes).."
]] elseif(page == "traffic_recording" and has_traffic_recording_page) then if not dismiss_recording_providers_reminder then print('
'..i18n('traffic_recording.msg_external_providers_detected', {url = ntop.getHttpPrefix().."/lua/if_stats.lua?page=config"})..'
') 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('') print('
') if recording_enabled and tab == "status" then dofile(dirs.installdir .. "/scripts/lua/inc/traffic_recording_status.lua") elseif recording_enabled and ntop.isEnterprise() 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 == "alerts") then drawAlertSourceSettings("interface", ifname_clean, i18n("show_alerts.iface_delete_config_btn", {iface=if_name}), "show_alerts.iface_delete_config_confirm", "if_stats.lua", {ifid=ifid}, if_name) elseif(page == "config") then if(not isAdministrator()) then return end print[[
]] if ((not interface.isPcapDumpInterface()) and (ifstats.name ~= nil) and (ifstats.name ~= "dummy")) then -- Custom name print[[ ]] -- Interface speed if not have_nedge then print[[ ]] -- Interface refresh rate print[[ ]] end end if not have_nedge then -- Scaling factor if interface.isPacketInterface() and not have_nedge then local label = ntop.getCache(getRedisIfacePrefix(ifid)..".scaling_factor") if((label == nil) or (label == "")) then label = "1" end print[[ ]] end end local rv = ntop.getMembersCache(getHideFromTopSet(ifstats.id)) or {} local members = {} -- impose sort order for _, net in pairsByValues(rv, asc) do members[#members + 1] = net end local hide_top = table.concat(members, ",") print[[ ]] -- Alerts local trigger_alerts = true local trigger_alerts_checked = "checked" if _SERVER["REQUEST_METHOD"] == "POST" then if _POST["trigger_alerts"] ~= "1" then trigger_alerts = false trigger_alerts_checked = "" end ntop.setHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), ifname_clean, tostring(trigger_alerts)) else trigger_alerts = ntop.getHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), ifname_clean) if trigger_alerts == "false" then trigger_alerts = false trigger_alerts_checked = "" end end print [[]] -- per-interface RRD generation local interface_rrd_creation = true local interface_rrd_creation_checked = "checked" if _SERVER["REQUEST_METHOD"] == "POST" then if _POST["interface_rrd_creation"] ~= "1" then interface_rrd_creation = false interface_rrd_creation_checked = "" end ntop.setPref("ntopng.prefs.ifid_"..ifId..".interface_rrd_creation", tostring(interface_rrd_creation)) else interface_rrd_creation = ntop.getPref("ntopng.prefs.ifid_"..ifId..".interface_rrd_creation") if interface_rrd_creation == "false" then interface_rrd_creation = false interface_rrd_creation_checked = "" end end print [[]] -- per-interface Network Discovery if not ntop.isnEdge() and interface.isPacketInterface() then local is_mirrored_traffic = false local is_mirrored_traffic_checked = "" local is_mirrored_traffic_pref = string.format("ntopng.prefs.ifid_%d.is_traffic_mirrored", ifId) if _SERVER["REQUEST_METHOD"] == "POST" then if _POST["is_mirrored_traffic"] == "1" then is_mirrored_traffic = true is_mirrored_traffic_checked = "checked" end ntop.setPref(is_mirrored_traffic_pref, ternary(is_mirrored_traffic == true, '1', '0')) interface.updateTrafficMirrored() else is_mirrored_traffic = ternary(ntop.getPref(is_mirrored_traffic_pref) == '1', true, false) if is_mirrored_traffic then is_mirrored_traffic_checked = "checked" end end print [[]] end -- per-interface Network Discovery if interface.isDiscoverableInterface() then local discover = require "discover_utils" local interface_network_discovery = true local interface_network_discovery_checked = "checked" if _SERVER["REQUEST_METHOD"] == "POST" then if _POST["interface_network_discovery"] ~= "1" then interface_network_discovery = false interface_network_discovery_checked = "" end ntop.setPref(discover.getInterfaceNetworkDiscoveryEnabledKey(ifId), tostring(interface_network_discovery)) else interface_network_discovery = ntop.getPref(discover.getInterfaceNetworkDiscoveryEnabledKey(ifId)) if interface_network_discovery == "false" then interface_network_discovery = false interface_network_discovery_checked = "" end end print [[]] end if has_traffic_recording_page or (true) then local cur_provider = recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) local providers = recording_utils.getAvailableTrafficRecordingProviders() -- only 1 provider means there's only the default ntopng -- so no need to show this extra menu entry if table.len(providers) > 1 then print [[ ]] end end print[[
]] print(i18n("if_stats_config.custom_name")) print[[ ]] local label = getHumanReadableInterfaceName(ifstats.name) inline_input_form("custom_name", "Custom Name", i18n("if_stats_config.custom_name_popup_msg"), label, isAdministrator(), 'autocorrect="off" spellcheck="false"') print[[
]] print(i18n("if_stats_config.interface_speed")) print[[ ]] local ifspeed = getInterfaceSpeed(ifstats.id) inline_input_form("ifSpeed", "Interface Speed", i18n("if_stats_config.interface_speed_popup_msg"), ifspeed, isAdministrator(), 'type="number" min="1"') print[[
]] print(i18n("if_stats_config.refresh_rate")) print[[ ]] local refreshrate = getInterfaceRefreshRate(ifstats.id) inline_input_form("ifRate", "Refresh Rate", i18n("if_stats_config.refresh_rate_popup_msg"), refreshrate, isAdministrator(), 'type="number" min="1"') print[[
]] print(i18n("if_stats_config.scaling_factor")) print[[ ]] inline_input_form("scaling_factor", "Scaling Factor", i18n("if_stats_config.scaling_factor_popup_msg"), label, isAdministrator(), 'type="number" min="1" step="1"') print[[
]] print(i18n("if_stats_config.hide_from_top_networks")) print[[ ]] print('') print[[
]] print(i18n("if_stats_config.trigger_interface_alerts")) print[[
]] print(i18n("if_stats_config.interface_rrd_creation")) print[[
]] print(i18n("if_stats_config.is_mirrored_traffic")) print[[
]] print(i18n("if_stats_config.interface_network_discovery")) print[[
]] print(i18n("traffic_recording.traffic_recording_provider")) 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 set_snmp_bound_interface(ifstats.id, snmp_host, snmp_interface) else local value = 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 = get_snmp_devices(ifstats.id) print[[
]] print[[
]] print(i18n("snmp.snmp_device")) print[[ ]] print(i18n("snmp.view_device")) print[[
]] print(i18n("snmp.snmp_interface")) print[[
]] print(i18n("snmp.note") .. ":") print[[
]] print(i18n("snmp.bound_interface_description")) print[[ ]] elseif(page == "pools") then if ifstats.isView then error() end dofile(dirs.installdir .. "/scripts/lua/admin/host_pools.lua") elseif page == "traffic_report" then dofile(dirs.installdir .. "/pro/scripts/lua/enterprise/traffic_report.lua") end print(" ]] print [[ ]] dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")