-- -- (C) 2013-22 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path if(ntop.isPro()) then package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path local snmp_utils = require "snmp_utils" end require "lua_utils" local graph_utils = require "graph_utils" local tag_utils = require("tag_utils") local page_utils = require("page_utils") local auth = require "auth" local network_id = _GET["network"] local network_name = _GET["network_cidr"] local page = _GET["page"] local subnet2 = _GET["subnet_2"] local network_behavior_update_freq = 300 -- Seconds local ifstats = interface.getStats() local ifId = ifstats.id if(not isEmptyString(network_name)) then network_id = ntop.getNetworkIdByName(network_name) else network_name = ntop.getNetworkNameById(tonumber(network_id)) end local custom_name = getLocalNetworkAlias(network_name) local network_vlan = tonumber(_GET["vlan"]) if network_vlan == nil then network_vlan = 0 end sendHTTPContentTypeHeader('text/html') page_utils.set_active_menu_entry(page_utils.menu_entries.networks) dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") if(network_id == nil) then print("
".. i18n("network_details.network_parameter_missing_message") .. "
") dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") return end --[[ Create Menu Bar with buttons --]] local nav_url = ntop.getHttpPrefix().."/lua/network_details.lua?network="..tonumber(network_id) local title = i18n("network_details.network") .. ": "..network_name page_utils.print_navbar(title, nav_url, { { active = page == "historical" or not page, page_name = "historical", label = "", }, { hidden = not areAlertsEnabled() or not auth.has_capability(auth.capabilities.alerts), active = page == "alerts", page_name = "alerts", url = ntop.getHttpPrefix() .. "/lua/alert_stats.lua?&page=network&network_name=" .. network_name .. tag_utils.SEPARATOR .. "eq", label = "", }, { hidden = not hasTrafficReport(), active = page == "traffic_report", page_name = "traffic_report", label = "", }, { hidden = not network_id or not isAdministrator(), active = page == "config", page_name = "config", label = "", }, } ) --[[ Selectively render information pages --]] if page == "historical" then local schema = _GET["ts_schema"] or "subnet:traffic" local selected_epoch = _GET["epoch"] or "" local url = ntop.getHttpPrefix()..'/lua/network_details.lua?ifid='..ifId..'&network='..network_id..'&page=historical' local tags = { ifid = ifId, subnet = network_name, subnet_2 = subnet2, } local timeseries = {} local all_timeseries = { {schema="subnet:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]}, {schema="subnet:broadcast_traffic", label=i18n("broadcast_traffic")}, {schema="subnet:engaged_alerts", label=i18n("show_alerts.engaged_alerts")}, {schema="subnet:score", label=i18n("score"), split_directions = true}, {schema="subnet:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1}, {schema="subnet:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1}, {schema="subnet:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1}, {schema="subnet:tcp_keep_alive", label=i18n("graphs.tcp_packets_keep_alive"), nedge_exclude=1}, } if ntop.isPro() then local pro_timeseries = { {schema="subnet:score_anomalies", label=i18n("graphs.iface_score_anomalies")}, {schema="subnet:score_behavior", label=i18n("graphs.iface_score_behavior"), split_directions = true, first_timeseries_only = true, metrics_labels = {i18n("graphs.score"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}}, {schema="subnet:traffic_anomalies", label=i18n("graphs.iface_traffic_anomalies")}, {schema="subnet:traffic_rx_behavior_v2", label=i18n("graphs.iface_traffic_rx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq, value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_rcvd"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}}, {schema="subnet:traffic_tx_behavior_v2", label=i18n("graphs.iface_traffic_tx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq,value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_sent"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}}, } all_timeseries = table.merge(all_timeseries, pro_timeseries) network.select(tonumber(network_id)) local net_stats = network.getNetworkStats() or {} local net_matrix_ts = {} for second_subnet, _ in pairs(net_stats["intranet_traffic"]) do local label_1 = getFullLocalNetworkName(network_name) local label_2 = getFullLocalNetworkName(second_subnet) net_matrix_ts[#net_matrix_ts + 1] = { schema="subnet:intranet_traffic", label= i18n("graphs.intranet_traffic", { net_1 = label_1, net_2 = label_2 }), split_directions = true --[[ split RX and TX directions ]], extra_params = { subnet_2 = second_subnet, } } end all_timeseries = table.merge(all_timeseries, net_matrix_ts) end timeseries["timeseries"] = all_timeseries graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, timeseries) elseif (page == "config") then if(not isAdministrator()) then return end print[[
]] if _SERVER["REQUEST_METHOD"] == "POST" then setLocalNetworkAlias(network_name, _POST["custom_name"]) custom_name = getLocalNetworkAlias(network_name) end print [[]] print[[
]] print(i18n("network_details.network_alias")) print[[


]] print([[
]] .. i18n("notes") .. [[:
]]) elseif page == "traffic_report" then package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/?.lua;" .. package.path local traffic_report = require "traffic_report" traffic_report.generate_traffic_report() end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")