-- -- (C) 2013-15 - 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 require "snmp_utils" end require "lua_utils" require "graph_utils" require "alert_utils" local network = _GET["network"] local page = _GET["page"] interface.select(ifname) ifstats = aggregateInterfaceStats(interface.getStats()) ifId = ifstats.id local network_name = ntop.getNetworkNameById(tonumber(network)) local network_vlan = tonumber(_GET["vlan"]) if network_vlan == nil then network_vlan = 0 end sendHTTPHeader('text/html; charset=iso-8859-1') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") if(network == nil) then print("
Network parameter is missing (internal error ?)
") return end rrdname = dirs.workingdir .. "/" .. ifId .. "/subnetstats/" .. getPathFromKey(network_name) .. "/bytes.rrd" if(not ntop.exists(rrdname)) then print("
No available stats for network "..network_name.."
") return end --[[ Process form data --]] if(_GET["flow_rate_alert_threshold"] ~= nil and _GET["csrf"] ~= nil) then if (tonumber(_GET["flow_rate_alert_threshold"]) ~= nil) then page = "config" local val = ternary(_GET["flow_rate_alert_threshold"] ~= "0", _GET["flow_rate_alert_threshold"], "25") ntop.setCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.flow_rate_alert_threshold', val) -- interface.loadHostAlertPrefs(network_name, network_vlan) TODO: decide to implement it for networks end end if(_GET["syn_alert_threshold"] ~= nil and _GET["csrf"] ~= nil) then if (tonumber(_GET["syn_alert_threshold"]) ~= nil) then page = "config" val = ternary(_GET["syn_alert_threshold"] ~= "0", _GET["syn_alert_threshold"], "10") ntop.setCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.syn_alert_threshold', val) -- interface.loadHostAlertPrefs(network_name, network_vlan) TODO: decide to implement it for networks end end if(_GET["flows_alert_threshold"] ~= nil and _GET["csrf"] ~= nil) then if (tonumber(_GET["flows_alert_threshold"]) ~= nil) then page = "config" val = ternary(_GET["flows_alert_threshold"] ~= "0", _GET["flows_alert_threshold"], "32768") ntop.setCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.flows_alert_threshold', val) -- interface.loadHostAlertPrefs(network_name, network_vlan) TODO: decide to implement it for networks end end --[[ Create Menu Bar with buttons --]] local nav_url = ntop.getHttpPrefix().."/lua/network_details.lua?network="..tonumber(network) print [[
]] --[[ Selectively render information pages --]] if page == "historical" then if(_GET["rrd_file"] == nil) then rrdfile = "bytes.rrd" else rrdfile=_GET["rrd_file"] end host_url = ntop.getHttpPrefix()..'/lua/network_details.lua?ifname='..ifId..'&network='..network..'&page=historical' drawRRD(ifId, 'net:'..network_name, rrdfile, _GET["graph_zoom"], host_url, 1, _GET["epoch"], nil, makeTopStatsScriptsArray()) elseif (page == "config") then if(isAdministrator()) then trigger_alerts = _GET["trigger_alerts"] if(trigger_alerts ~= nil) then if(trigger_alerts == "true") then ntop.delHashCache("ntopng.prefs.alerts", network_name) else ntop.setHashCache("ntopng.prefs.alerts", network_name, trigger_alerts) end end end local flow_rate_alter_thresh = ntop.getCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.flow_rate_alert_threshold') local syn_alert_thresh = ntop.getCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.syn_alert_threshold') local flows_alert_thresh = ntop.getCache('ntopng.prefs.'..network_name..':'..tostring(network_vlan)..'.flows_alert_threshold') if (flow_rate_alter_thresh == nil or flow_rate_alter_thresh == "") then flow_rate_alter_thresh = 25 end if (syn_alert_thresh == nil or syn_alert_thresh == "") then syn_alert_thresh = 10 end if (flows_alert_thresh == nil or flows_alert_thresh == "") then flows_alert_thresh = 32768 end print("\n") print("\n") print [[ ]] print("\n") print [[ ]] print("\n") print [[ ]] local suppressAlerts = ntop.getHashCache("ntopng.prefs.alerts", network_name) if((suppressAlerts == "") or (suppressAlerts == nil) or (suppressAlerts == "true")) then alerts_checked = 'checked="checked"' alerts_value = "false" -- Opposite else alerts_checked = "" alerts_value = "true" -- Opposite end print [[ ') print [[]] print("
Network Flow Alert Threshold]] print[[
]] print('\n') print('  
Max number of new flows/sec over which the network is considered to be flooding (Experimental). Default: 25.
]] print[[
Network SYN Alert Threshold]] print[[
]] print('\n') print [[  
Max number of sent TCP SYN packets/sec over which the network is considered to be flooding (Experimental). Default: 10.
]] print[[
Network Flows Threshold]] print[[
]] print('\n') print [[  
Max number of flows over which the network is considered to be flooding (Experimental). Default: 32768.
]] print[[
Network Alerts
Trigger alerts for network '..network_name..'') print('\n') print('') print('
') print('
") elseif(page == "alerts") then local tab = _GET["tab"] local re_arm_minutes = nil if(tab == nil) then tab = alerts_granularity[1][1] end print('