-- -- (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 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" 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 have_nedge = ntop.isnEdge() if ntop.isPro() then shaper_utils = require("shaper_utils") end local show_bridge_wizard = false 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 pcap dump is disabled if the nbox integration is enabled or -- if the user is not an administrator or if the interface: -- is a view -- is not a packet interface (i.e., it is zmq) local is_packetdump_enabled = isLocalPacketdumpEnabled() 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 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 if is_packetdump_enabled and (page == "packetdump") and (_SERVER["REQUEST_METHOD"] == "POST") then ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_all_traffic', ternary(isEmptyString(_POST["dump_all_traffic"]), "false", "true")) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_tap', ternary(isEmptyString(_POST["dump_traffic_to_tap"]), "false", "true")) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_disk', ternary(isEmptyString(_POST["dump_traffic_to_disk"]), "false", "true")) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_unknown_traffic', ternary(isEmptyString(_POST["dump_unknown_to_disk"]), "false", "true")) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_sampling_rate', _POST["sampling_rate"]) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_pkts_file', _POST["max_pkts_file"]) ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_sec_file',_POST["max_sec_file"]) local max_files = ternary(not isEmptyString(_POST["max_files"]), _POST["max_files"], 500) max_files = tonumber(max_files) * 1e6 ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_files', tostring(max_files)) interface.loadDumpPrefs() end if recording_utils.isAvailable() and page == "traffic_recording" and _SERVER["REQUEST_METHOD"] == "POST" then local record_traffic = false if not isEmptyString(_POST["record_traffic"]) then record_traffic = true end ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled', ternary(record_traffic, "true", "false")) local disk_space = recording_utils.default_disk_space if not isEmptyString(_POST["disk_space"]) then disk_space = tonumber(_POST["disk_space"])*1024 end ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.disk_space', tostring(disk_space)) if record_traffic then local config = {} config.max_disk_space = disk_space recording_utils.createConfig(ifstats.id, config) recording_utils.restart(ifstats.id) else recording_utils.stop(ifstats.id) end end end ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") 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 = 3 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("") 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 if(ifstats["pkt_dumper"] ~= nil) then print("\n") print("") print("\n") 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("") end print("\n") print("") if ifstats.isDynamic == false then print("") print("") else print("") end print("") 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 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 and ifstats.isDynamic == false) 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.."
'..i18n("name")..'' .. s ..'
"..i18n("bridge")..""..ifstats["bridge.device_a"].." "..ifstats["bridge.device_b"]) if(user_group == "administrator") and isBridgeInterface(ifstats) and ntop.isEnterprise() and not have_nedge then print[[ ]] show_bridge_wizard = true end 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) .. "
"..i18n("if_stats_overview.packet_dumper")..""..i18n("if_stats_overview.dumped_packets")..""..i18n("if_stats_overview.dumped_files").."
".. formatValue(ifstats["pkt_dumper"]["num_dumped_pkts"]) .."
".. formatValue(ifstats["pkt_dumper"]["num_dumped_files"]) .."
]] 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.ingress_traffic").."
"..i18n("if_stats_overview.received_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("
"..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("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") if show_bridge_wizard then dofile(dirs.installdir .. "/scripts/lua/inc/bridge_wizard.lua") end 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 --fc = interface.getnDPIFlowsCount() --for k,v in pairs(fc) do -- io.write(k.."="..v.."\n") --end 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("ndpi_page.application_protocol")})) print [[
]] print(i18n("ndpi_page.overview", {what = i18n("ndpi_page.application_protocol_category")})) 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 [[ ]] print("\n") print ('\n') print ("") print("
" .. i18n("ndpi_page.application_protocol") .. "" .. i18n("ndpi_page.total_since_startup") .. "" .. i18n("percentage") .. "
\n") print [[ ]] print [[ ]] print("\n") print ('\n') print ("") print("
" .. i18n("ndpi_page.application_protocol_category") .. "" .. i18n("ndpi_page.total_since_startup") .. "" .. i18n("percentage") .. "
\n") 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: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}, {separator=1, nedge_exclude=1}, {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}, {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 == "packetdump") then if is_packetdump_enabled then local dump_all_traffic = ntop.getCache('ntopng.prefs.'..ifstats.name..'.dump_all_traffic') local dump_unknown_traffic = ntop.getCache('ntopng.prefs.'..ifstats.name..'.dump_unknown_traffic') local dump_status_tap = ntop.getCache('ntopng.prefs.'..ifstats.name..'.dump_tap') local dump_status_disk = ntop.getCache('ntopng.prefs.'..ifstats.name..'.dump_disk') if(dump_all_traffic == "true") then dump_all_traffic_checked = 'checked="checked"' dump_all_traffic_value = "false" -- Opposite else dump_all_traffic_checked = "" dump_all_traffic_value = "true" -- Opposite end if(dump_status_disk == "true") then dump_traffic_checked = 'checked="checked"' dump_traffic_value = "false" -- Opposite else dump_traffic_checked = "" dump_traffic_value = "true" -- Opposite end if(dump_unknown_traffic == "true") then dump_unknown_checked = 'checked="checked"' dump_unknown_value = "false" -- Opposite else dump_unknown_checked = "" dump_unknown_value = "true" -- Opposite end if(dump_status_tap == "true") then dump_traffic_tap_checked = 'checked="checked"' dump_traffic_tap_value = "false" -- Opposite else dump_traffic_tap_checked = "" dump_traffic_tap_value = "true" -- Opposite end print("

") print("\n") print('\n') print("\n") print("\n") print("\n") print("\n") print("\n") print [[ ]] print("") print("\n") print("\n") print [[ ]] print("\n") print [[ ]] print("\n") print [[]] print("
" .. i18n("packetdump_page.packet_dump") .. "") print(''..' '..i18n("packetdump_page.dump_all_traffic")) print('') print("
") print(' '..i18n("packetdump_page.dump_unknown_traffic")..' ') print("
" .. i18n("packetdump_page.packet_dump_to_disk").. "") print(' '..i18n("packetdump_page.dump_traffic_to_disk")) if(dump_traffic_checked ~= "") then local dumped = interface.getInterfacePacketsDumpedFile() print(" - " .. i18n("packetdump_page.num_dumped_packets",{num_pkts=ternary(dumped, dumped, 0)})) end print('') print("
" .. i18n("packetdump_page.packet_dump_to_tap") .. "") if(interface.getInterfaceDumpTapName() ~= "") then print(' '..i18n("packetdump_page.dump_traffic_to_tap")..' ') print('('..interface.getInterfaceDumpTapName()..')') if(dump_traffic_tap_checked ~= "") then dumped = interface.getInterfacePacketsDumpedTap() print(" - " .. i18n("packetdump_page.num_dumped_packets",{num_pkts=ternary(dumped, dumped, 0)})) end print(' ') else print(i18n("packetdump_page.packet_dump_to_tap_disabled_message")) end print("
"..i18n("packetdump_page.sampling_rate").."]] print [[
" .. i18n("packetdump_page.dump_to_disk_parameters") .. "
" .. i18n("packetdump_page.pcap_dump_directory") .. "") pcapdir = dirs.workingdir .."/"..ifstats.id.."/pcap/" print(pcapdir.."
" .. i18n("packetdump_page.max_packets_per_file") .. "]] print [[ pkts
]] print(i18n("packetdump_page.max_packets_per_file_description")) print [[
" .. i18n("packetdump_page.max_duration_file") .. "]] print [[ sec
]] print(i18n("packetdump_page.max_duration_file_description") .. "
") print(i18n("packetdump_page.note") .. ": " .. i18n("packetdump_page.note_max_duration_file")) print[[
" .. i18n("packetdump_page.max_dump_files") .. "]] print [[ MB
]] print(i18n("packetdump_page.max_size_dump_files_description")) print[[
]] print(i18n("packetdump_page.note") .. ": " .. i18n("packetdump_page.note_max_size_dump_files")) print[[
") print[[

]] print("
") print[[]] end elseif(page == "traffic_recording") then if recording_utils.isAvailable() then local record_traffic = ntop.getCache('ntopng.prefs.ifid_'..ifid..'.traffic_recording.enabled') local disk_space = ntop.getCache('ntopng.prefs.ifid_'..ifid..'.traffic_recording.disk_space') local storage_info = recording_utils.storageInfo() if record_traffic == "true" then record_traffic_checked = 'checked="checked"' record_traffic_value = "false" -- Opposite else record_traffic_checked = "" record_traffic_value = "true" -- Opposite end if isEmptyString(disk_space) then disk_space = storage_info.avail - (storage_info.avail*0.2) -- default (recommended value) end disk_space = tostring(math.floor(tonumber(disk_space)/1024)) print [[
]] print [[ ]] print [[
]] print(i18n("traffic_recording.traffic_recording")) print [[ ]] print(i18n("traffic_recording.continuous_recording")) print [[
]] print(i18n("traffic_recording.disk_space")) print [[ GB
]] print(i18n("traffic_recording.disk_space_note")) print[[
]] print(i18n("traffic_recording.storage_dir")) print [[ ]] print(recording_utils.getPcapPath(ifid)) print [[
]] print(i18n("traffic_recording.storage_utilization")) print [[
]] print(tostring(math.floor(storage_info.used/1024))) print [[ GB / ]] print(tostring(math.floor(storage_info.total/1024))) print [[ GB (]] print(storage_info.used_perc) print [[)


]] end 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 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[[


]] 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")