-- -- (C) 2013-17 - 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" end local json = require "dkjson" local host_pools_utils = require "host_pools_utils" local template = require "template_utils" require "lua_utils" require "prefs_utils" require "graph_utils" require "alert_utils" require "db_utils" if ntop.isPro() then shaper_utils = require("shaper_utils") end sendHTTPHeader('text/html; charset=iso-8859-1') 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_clss) print [[
\n") 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 = "| 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 | ' .. s ..' | \n') else print("|||||||
| Bridge | "..ifstats["bridge.device_a"].." "..ifstats["bridge.device_b"].." | ") end print("Family | ") print(ifstats.type) if(ifstats.inline) then print(" In-Path Interface (Bump in the Wire)") end print(" | |||||
| 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(" | |||||||
| MTU | "..ifstats.mtu.." bytes | \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("Speed | " .. maxRateToString(speed*1000) .. " | ") else 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).." | ZMQ Message Drops | "..formatValue(ifstats.zmqRecvStats.zmq_msg_drops).."") end print(" | |
| 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(" | ") 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(" | ||||
| Reset Counters | ") print("") local cls = "" 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 if tot == 0 then cls = " disabled" end print(' ') cls = "" if(ifstats.stats.flow_export_count ~= nil) then if ifstats.stats.drops + ifstats.stats.flow_export_drops == 0 then cls = " disabled" end end print('') print(" | ") print("|||||||
| Bridged Traffic | ||||||||
| Interface Direction | Ingress Packets | Egress Packets | Shaped/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.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.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. |
| Custom Name | ]] local 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[[ |
|---|---|
| Scaling Factor | ]] 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') print[[ |