-- -- (C) 2013-15 - 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 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"] if(if_name == nil) then if_name = ifname end max_num_shapers = 10 interface.select(if_name) ifid = interface.name2id(ifname) shaper_key = "ntopng.prefs."..ifid..".shaper_max_rate" ifstats = aggregateInterfaceStats(interface.getStats()) if(_GET["custom_name"] ~=nil) then if(_GET["csrf"] ~= nil) then ntop.setCache('ntopng.prefs.'..ifstats.name..'.name',_GET["custom_name"]) end end if(_GET["dump_all_traffic"] ~= nil and _GET["csrf"] ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_all_traffic',_GET["dump_all_traffic"]) interface.loadDumpPrefs() end if(_GET["dump_traffic_to_tap"] ~= nil and _GET["csrf"] ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_tap',_GET["dump_traffic_to_tap"]) interface.loadDumpPrefs() end if(_GET["dump_traffic_to_disk"] ~= nil and _GET["csrf"] ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_disk',_GET["dump_traffic_to_disk"]) interface.loadDumpPrefs() end if(_GET["dump_unknown_to_disk"] ~= nil and _GET["csrf"] ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_unknown_disk',_GET["dump_unknown_to_disk"]) interface.loadDumpPrefs() end if(_GET["dump_security_to_disk"] ~= nil and _GET["csrf"] ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_security_disk',_GET["dump_security_to_disk"]) interface.loadDumpPrefs() end if(_GET["sampling_rate"] ~= nil and _GET["csrf"] ~= nil) then if(tonumber(_GET["sampling_rate"]) ~= nil) then page = "packetdump" val = ternary(_GET["sampling_rate"] ~= "0", _GET["sampling_rate"], "1") ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_sampling_rate', val) interface.loadDumpPrefs() end end if(_GET["max_pkts_file"] ~= nil and _GET["csrf"] ~= nil) then if(tonumber(_GET["max_pkts_file"]) ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_pkts_file',_GET["max_pkts_file"]) interface.loadDumpPrefs() end end if(_GET["max_sec_file"] ~= nil and _GET["csrf"] ~= nil) then if(tonumber(_GET["max_sec_file"]) ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_sec_file',_GET["max_sec_file"]) interface.loadDumpPrefs() end end if(_GET["max_files"] ~= nil and _GET["csrf"] ~= nil) then if(tonumber(_GET["max_files"]) ~= nil) then page = "packetdump" local max_files_size = tonumber(_GET["max_files"]) max_files_size = max_files_size * 1000000 ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_files', tostring(max_files_size)) interface.loadDumpPrefs() end end ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") print("") active_page = "if_stats" dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") rrdname = fixPath(dirs.workingdir .. "/" .. ifstats.id .. "/rrd/bytes.rrd") if(if_name == nil) then _ifname = ifname else _ifname = if_name end url= ntop.getHttpPrefix()..'/lua/if_stats.lua?if_name=' .. _ifname -- 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("
| 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(" | ||||||||
| Name | " .. ifstats.name .. " | \n") if(ifstats.name ~= nil) then label = getInterfaceNameAlias(ifstats.name) if(not isAdministrator()) then print("") else print(" | ") end print [[ | ||||||
| Speed | " .. maxRateToString(ifstats.speed*1000) .. " | MTU | "..ifstats.mtu.." bytes | ||||||
| IP Address | ")
for _,s in pairs(tokens) do
t = string.split(s, "/")
host = interface.getHostInfo(t[1])
if(host ~= nil) then
print(" | ||||||||
| Family | ") if(ifstats.isView == true) then print(" ") end print(ifstats.type) if(ifstats.inline) then print(" In-Path Interface (Bump in the Wire)") elseif(ifstats.isView == true) then print(" (Aggregated Interface View)") end print(" | ||||||||
| Packet Dumper | Dumped Packets | Dumped Files | |||||||
".. formatValue(ifstats["pkt_dumper"]["num_dumped_pkts"]) .." | ")
print("".. formatValue(ifstats["pkt_dumper"]["num_dumped_files"]) .." | ||||||||
| Traffic Breakdown | |||||||||
| Ingress Traffic | |||||||||
| Received Traffic | "..bytesToSize(ifstats.bytes).." [".. formatValue(ifstats.packets) .. " ".. label .."] ") print(" | Dropped Packets | ") if(ifstats.drops > 0) then print('') end print(formatValue(ifstats.drops).. " " .. label) if((ifstats.packets+ifstats.drops) > 0) then local pctg = round((ifstats.drops*100)/(ifstats.packets+ifstats.drops), 2) if(pctg > 0) then print(" [ " .. pctg .. " % ] ") end end if(ifstats.drops > 0) then print('') end 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. | |||||||||
| Size Distribution | |||||
|---|---|---|---|---|---|
]] elseif(page == "ndpi") then --fc = interface.getnDPIFlowsCount() --for k,v in pairs(fc) do -- io.write(k.."="..v.."\n") --end print [[
| Protocol Overview | |||||
|---|---|---|---|---|---|
| Live Flows Count | |||||
| Application Protocol | Total (Since Startup) | Percentage |
|---|
| Profile Name | Graph | 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 print(' [ Delete '.. selected_network ..' ]') 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. |
| Add VLAN/Network To Filter | |
|
Local Network :
VLAN
|
|