-- -- (C) 2013-16 - 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 "common" local json = require "dkjson" end require "lua_utils" require "prefs_utils" require "graph_utils" require "alert_utils" require "db_utils" sendHTTPHeader('text/html; charset=iso-8859-1') page = _GET["page"] if_name = _GET["if_name"] ifid = (_GET["id"] or _GET["ifId"]) msg = "" function inline_input_form(name, placeholder, tooltip, value, can_edit, input_opts, input_clss) print [[
\n") end if(_GET["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 = "| Id | " .. ifstats.id .. " ") print(" | ||||||
|---|---|---|---|---|---|---|---|
| State | ") state = toggleTableButton("", "", "Active", "1","primary", "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(" | ||||||
| Remote Probe | Interface Name: "..ifstats["remote.name"].." [ ".. maxRateToString(ifstats.speed*1000) .." ] | ") if(ifstats["remote.if_addr"] ~= "") then print("Interface IP: "..ifstats["remote.if_addr"].." | ") end if(ifstats["probe.ip"] ~= "") then print("Probe IP: "..ifstats["probe.ip"].." | ") end if(ifstats["probe.public_ip"] ~= "") then print(" | Public Probe IP: "..ifstats["probe.public_ip"].." | \n") else print("\n") end print(" | |
| Name | ' .. ifstats.name..' | \n') if is_physical_iface then if(ifstats.name ~= nil) then print('Custom Name | ') label = getInterfaceNameAlias(ifstats.name) inline_input_form("custom_name", "Custom Name", "Specify an alias for the interface", label, isAdministrator(), 'autocorrect="off" spellcheck="false" pattern="^[_\\-a-zA-Z0-9]*$"') print(" | ||||
| Speed | " .. maxRateToString(speed*1000) .. " | ") if interface.isPacketInterface() then print("Scaling Factor | ") local label = ntop.getCache(getRedisIfacePrefix(ifid)..".scaling_factor") if((label == nil) or (label == "")) then label = "1" end inline_input_form("scaling_factor", "Scaling Factor", "This should match your capture interface sampling rate", label, isAdministrator(), 'type="number" min="1" step="1"', 'no-spinner') end print(" | ") end else print(" | |||
| Bridge | "..ifstats["bridge.device_a"].." "..ifstats["bridge.device_b"].." | ||||||
| IP Address | ")
for _,s in pairs(tokens) do
t = string.split(s, "/")
host = interface.getHostInfo(t[1])
if(host ~= nil) then
print(" | ||||||
| Family | ") print(ifstats.type) if(ifstats.inline) then print(" In-Path Interface (Bump in the Wire)") end if is_physical_iface then print(" | MTU | "..ifstats.mtu.." bytes | ") end if(ifstats["pkt_dumper"] ~= nil) then print(" | |||
| Packet Dumper | Dumped Packets | Dumped Files | |||||
".. formatValue(ifstats["pkt_dumper"]["num_dumped_pkts"]) .." | ")
print("".. formatValue(ifstats["pkt_dumper"]["num_dumped_files"]) .." | ||||||
| Traffic Breakdown | ]] if(ifstats.type ~= "zmq") then print [[]] end print [[ \n") if(ifstats.zmqRecvStats ~= nil) then print(" | ||||||
| ZMQ RX Statistics | |||||||
| Collected Flows | "..formatValue(ifstats.zmqRecvStats.flows).."") print(" | Interface RX Updates | "..formatValue(ifstats.zmqRecvStats.events).."") print(" | sFlow Counter Updates | "..formatValue(ifstats.zmqRecvStats.counters).." | ||
| Ingress Traffic | |||||||
| Received Traffic | "..bytesToSize(ifstats.stats.bytes).." [".. formatValue(ifstats.stats.packets) .. " ".. label .."] ") print(" | 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(" | ||||
| "..dump_to.." Flows Export Statistics | |||||||
| Exported Flows | ") print(""..formatValue(export_count).."") print(" ["..formatValue(round(export_rate, 2)).." Flows/s] | ") print("Dropped Flows | ") local span_danger = "" if(export_drops > 0) then span_danger = ' class="label label-danger"' end print(""..formatValue(export_drops).." ") print("[" ..formatValue(round(export_drops_pct, 2)).."%] | ") print("") print(" | |||
| Bridged Traffic | |||||||
| Interface Direction | Ingress Packets | Egress Packets | Shaped Packets | Filtered Packets | Send Error | Buffer Full | |
| ".. ifstats["bridge.device_a"] .. " ".. ifstats["bridge.device_b"] .." | ".. formatPackets(ifstats["bridge.a_to_b.in_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.a_to_b.out_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.a_to_b.shaped_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.a_to_b.filtered_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.a_to_b.num_pkts_send_error"]) .." | ") print("".. formatPackets(ifstats["bridge.a_to_b.num_pkts_send_buffer_full"]) .." | ") print("|
| ".. ifstats["bridge.device_b"] .. " ".. ifstats["bridge.device_a"] .." | ".. formatPackets(ifstats["bridge.b_to_a.in_pkts"]) .." | ") print(""..formatPackets( ifstats["bridge.b_to_a.out_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.b_to_a.shaped_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.b_to_a.filtered_pkts"]) .." | ") print("".. formatPackets(ifstats["bridge.b_to_a.num_pkts_send_error"]) .." | ") print("".. formatPackets(ifstats["bridge.b_to_a.num_pkts_send_buffer_full"]) .." | ") print("|
| NOTE: In ethernet networks, each packet has an overhead of 24 bytes [preamble (7 bytes), start of frame (1 byte), CRC (4 bytes), and IFG (12 bytes)]. Such overhead needs to be accounted to the interface traffic, but it is not added to the traffic being exchanged between IP addresses. This is because such data contributes to interface load, but it cannot be accounted in the traffic being exchanged by hosts, and thus expect little discrepancies between host and interface traffic values. | |||||||
| TCP Packets Analysis | Retransmissions | ".. formatPackets(ifstats.tcpPacketStats.retransmissions) .." | |||
|---|---|---|---|---|---|
| Out of Order | ".. formatPackets(ifstats.tcpPacketStats.out_of_order) .." | ||||
| Lost | ".. formatPackets(ifstats.tcpPacketStats.lost) .." | ||||
| Size Distribution | |||||
]] elseif(page == "ndpi") then --fc = interface.getnDPIFlowsCount() --for k,v in pairs(fc) do -- io.write(k.."="..v.."\n") --end print [[
| Cumulative Protocol Stats | |||||
|---|---|---|---|---|---|
| Live Flows Count |
NOTE: This chart depicts only TCP connections. |
||||
| Application Protocol | Total (Since Startup) | Percentage |
|---|
| Profile Name | Chart | Traffic |
|---|---|---|
| "..pname.." | "..statschart_icon.." | "..bytesToSize(pbytes).." |
| Packet Dump | ") print [[ ') print(" |
|---|---|
| Packet Dump To Disk | ") print [[ ') print(" |
| ") print [[ ') print(" | |
| ") print [[ ') print(" | |
| Packet Dump To Tap | ") if(interface.getInterfaceDumpTapName() ~= "") then print [[ ') else print("Disabled. Please restart ntopng with --enable-taps") end print(" |
| Sampling Rate | \n") print [[]]
if(dump_security_checked ~= "") then
print[[
NOTE: Sampling rate is applied only when dumping packets caused by a security alert (e.g. a volumetric DDoS attack) and not to those hosts/flows that have been marked explicitly for dump. ]] else print('Disabled. Enable packet dump on security alert.') end print[[ |
| Dump To Disk Parameters | |
| Pcap Dump Directory | ") pcapdir = dirs.workingdir .."/"..ifstats.id.."/pcap/" print(pcapdir.." |
| Max Packets per File | \n") print [[Maximum number of packets to store on a pcap file before creating a new file. |
| Max Duration of File | \n") print [[
Maximum pcap file duration before creating a new file. NOTE: a dump file is closed when it reaches first the maximum size or duration specified. |
| Max Size of Dump Files | \n") print [[
Maximum size of created pcap files. NOTE: total file size is checked daily and old dump files are automatically overwritten after reaching the threshold. |
| Alert Function | Threshold |
|---|
| Interface Alerts |
| ')
print [[
|---|
| Shaper Id | Max Rate |
|---|---|
| '..i) print [[ |
| Manage Traffic Filtering Policies | |
|---|---|
| Network: | ]] if((selected_found == true) and (string.contains(selected_network, "/32") or string.contains(selected_network, "/128"))) then nw = string.gsub(selected_network, "/32", ""); nw = string.gsub(nw, "/128", ""); print(" [ Show Host ] ") end if selected_network ~= any_net then print(' [ Delete '.. selected_network ..' ]') end print(' |
| Ingress Shaper Id |
Specify the max ingress transmission bandwidth to be associated to this network/host. |
| Egress Shaper Id |
Specify the max egress transmission bandwidth to be associated to this network/host. |
| Create Traffic Filtering Policy | |
|---|---|
| Target Network: | ]] locals = ntop.getLocalNetworks() locals_empty = (next(locals) == nil) print[[ ]] if not locals_empty then print('') print('') end print[[ |
| Initial Policy: |
|
| VLAN | |