-- -- (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" require "snmp_utils" 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 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) 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 = "| "..i18n("if_stats_overview.id").." | " .. ifstats.id .. " ") 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) .." ] | ") if(ifstats["remote.if_addr"] ~= "") then print(""..i18n("if_stats_overview.interface_ip")..": "..ifstats["remote.if_addr"].." | ") end if(ifstats["probe.ip"] ~= "") then print(""..i18n("if_stats_overview.probe_ip")..": "..ifstats["probe.ip"].." | ") end if(ifstats["probe.public_ip"] ~= "") then print(" | "..i18n("if_stats_overview.public_probe_ip")..": "..ifstats["probe.public_ip"].." | \n") else print("\n") end print(" | ||
| '..i18n("name")..' | ' .. s ..' | \n') else print("|||||||
| "..i18n("bridge").." | "..ifstats["bridge.device_a"].." "..ifstats["bridge.device_b"].." | ") end print(""..i18n("if_stats_overview.family").." | ") print(ifstats.type) if(ifstats.inline) then print(" "..i18n("if_stats_overview.in_path_interface")) 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").." | \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(""..i18n("speed").." | " .. maxRateToString(speed*1000) .. " | ") else print("|||||
| "..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"]) .." | ")
print("".. formatValue(ifstats["pkt_dumper"]["num_dumped_files"]) .." | |||||||
| ]] print(i18n("if_stats_overview.traffic_breakdown")) print[[ | ]] if(ifstats.type ~= "zmq") then print [[]] end print [[ \n") if(ifstats.zmqRecvStats ~= nil) then print(" | |||||||
| "..i18n("if_stats_overview.zmq_rx_statistics").." | ||||||||
| "..i18n("if_stats_overview.collected_flows").." | "..formatValue(ifstats.zmqRecvStats.flows).."") print(" | "..i18n("if_stats_overview.interface_rx_updates").." | "..formatValue(ifstats.zmqRecvStats.events).."") -- print(" | "..i18n("if_stats_overview.sflow_counter_updates").." | "..formatValue(ifstats.zmqRecvStats.counters).." | "..i18n("if_stats_overview.zmq_message_drops").." | "..formatValue(ifstats.zmqRecvStats.zmq_msg_drops).."") end print(" | |
| "..i18n("if_stats_overview.ingress_traffic").." | ||||||||
| "..i18n("if_stats_overview.received_traffic").." | "..bytesToSize(ifstats.stats.bytes).." [".. formatValue(ifstats.stats.packets) .. " ".. label .."] ") 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 == null or ifstats.stats.drops == null then
elseif((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(ntop.getCache("ntopng.prefs.dynamic_iface_vlan_creation") == "1") then
if(ifstats.type == "Dynamic VLAN") then
print(" "..i18n("if_stats_overview.note")..": "..i18n("if_stats_overview.note_drop_ifstats_dynamic_vlan").."") else print(" "..i18n("if_stats_overview.note")..": "..i18n("if_stats_overview.note_drop_ifstats_not_dynamic_vlan").."") end end print(" | ") print(" | ||||
| "..dump_to.." "..i18n("if_stats_overview.flows_export_statistics").." | ||||||||
| "..i18n("if_stats_overview.exported_flows").." | ") print(""..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").." | ") local span_danger = "" if export_drops == nil then elseif(export_drops > 0) then span_danger = ' class="label label-danger"' end print(""..formatValue(export_drops).." ") print("[" ..formatValue(round(export_drops_pct, 2)).."%] | ") print("") print(" | ||||
| "..i18n("if_stats_overview.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("|||||||
| "..i18n("if_stats_overview.bridged_traffic").." | ||||||||
| "..i18n("interface").." | "..i18n("if_stats_overview.ingress_packets").." | "..i18n("if_stats_overview.egress_packets").." | "..i18n("if_stats_overview.shaped_filtered_packets").." | "..i18n("if_stats_overview.send_error").." | "..i18n("if_stats_overview.buffer_full").." | |||
| ".. ifstats["bridge.device_a"] .. " | ".. 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"] .. " | ".. 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("|||
| ]] print(i18n("if_stats_overview.note")..": "..i18n("if_stats_overview.note_packets")) print[[ | ||||||||
| TCP Packets Analysis | Retransmissions | ".. formatPackets(ifstats.tcpPacketStats.retransmissions) .." | |||
|---|---|---|---|---|---|
| Out of Order | ".. formatPackets(ifstats.tcpPacketStats.out_of_order) .." | ||||
| Lost | ".. formatPackets(ifstats.tcpPacketStats.lost) .." | ||||
| Size Distribution | |||||
| TCP Flags Distribution | |||||
| IP Version 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 |
|---|
| ICMP Message | Traffic |
|---|
| ARP Type | Traffic |
|---|
| 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[[ |
|---|---|
| Interface Speed (Mbit/s) | ]] local ifspeed = getInterfaceSpeed(ifstats) inline_input_form("ifSpeed", "Interface Speed", "Specify the maximum interface speed", ifspeed, isAdministrator(), 'type="number" min="1"') print[[ |
| Realtime Stats Refresh Rate (sec) | ]] local refreshrate = getInterfaceRefreshRate(ifstats.id) inline_input_form("ifRate", "Refresh Rate", "Specify the stats refresh rate for the interface", refreshrate, isAdministrator(), 'type="number" min="1"') 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"') print[[ |
| Trigger Interface Alerts |