-- -- (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 "graph_utils" sendHTTPHeader('text/html; charset=iso-8859-1') local function makeTopStatsScriptsArray() path = dirs.installdir .. "/scripts/lua/modules/top_scripts" path = fixPath(path) local files = ntop.readdir(path) topArray = {} for k,v in pairs(files) do if(v ~= nil) then value = {} fn,ext = v:match("([^.]+).([^.]+)") mod = require("top_scripts."..fn) if(type(mod) ~= type(true)) then value["name"] = mod.name value["script"] = mod.infoScript value["key"] = mod.infoScriptKey value["levels"] = mod.numLevels topArray[fn] = value end end end return(topArray) end 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..".queue_max_rate" is_historical = interface.isHistoricalInterface(ifid) ifstats = 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" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_files',_GET["max_files"]) 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 if not is_historical then print('\n\n') else print('\n\n') end 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 = ntop.getCache('ntopng.prefs.'..ifstats.name..'.name') if(isAdministrator()) then print("") else print(" | ") end print [[ | |||
| Description | " .. ifstats.description .. " | |||||
| Family | " .. ifstats.type) if(ifstats.iface_inline) then print(" In-Path Interface (Bump in the Wire)") elseif(ifstats.iface_view) then print(" (Aggregated Interface View)") end print(" | |||||
| Bytes | " .. bytesToSize(ifstats.stats_bytes) .. " ");
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 Packets | "..bytesToSize(ifstats.stats_bytes).." [".. formatValue(ifstats.stats_packets) .. " ".. label .."] | 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(" | |||
| Bridged Traffic | ||||||
| Interface Direction | Ingress Packets | Egress Packets | Filtered Packets | |||
| ".. 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"]) .." | ".. formatPackets(ifstats["bridge.a_to_b.filtered_pkts"]) .." | |||
| ".. 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"]) .." | ".. formatPackets(ifstats["bridge.b_to_a.filtered_pkts"]) .." | |||
| 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 |
|---|
| 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 | |
| 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. |
| Shaper Id | Max Rate (Kbps) | Presets |
|---|---|---|
| '..i) print [[ |