-- -- (C) 2013-21 - ntop.org -- require "lua_utils" local graph_utils = require "graph_utils" local recording_utils = require "recording_utils" local template = require "template_utils" local format_utils = require "format_utils" local ifstats = interface.getStats() local info = ntop.getInfo() if((not isAdministrator()) or (not recording_utils.isAvailable())) then return end -- POST check if(_SERVER["REQUEST_METHOD"] == "POST") then local record_traffic = false if not isEmptyString(_POST["record_traffic"]) then record_traffic = true ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled', "1") else ntop.delCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled') end local disk_space = recording_utils.default_disk_space if not isEmptyString(_POST["disk_space"]) then disk_space = tonumber(_POST["disk_space"])*1024 end ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.disk_space', tostring(disk_space)) if recording_utils.isSupportedZMQInterface(ifid) then local ext_ifname if not isEmptyString(_POST["custom_name"]) then -- param check for ifname,_ in pairs(recording_utils.getExtInterfaces(ifid)) do if ifname == _POST["custom_name"] then ext_ifname = ifname break end end end if ext_ifname ~= nil then ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.ext_ifname', ext_ifname) end end if record_traffic then local config = {} config.max_disk_space = disk_space if recording_utils.isSupportedZMQInterface(ifid) then config.zmq_endpoint = recording_utils.getZMQProbeAddr(ifid) recording_utils.stop(ifstats.id) -- stop before starting as the interface can be changed end if recording_utils.createConfig(ifstats.id, config) then recording_utils.restart(ifstats.id) end else recording_utils.stop(ifstats.id) end end local record_traffic = false if ntop.getCache('ntopng.prefs.ifid_'..ifid..'.traffic_recording.enabled') == "1" then record_traffic = true end local disk_space = ntop.getCache('ntopng.prefs.ifid_'..ifid..'.traffic_recording.disk_space') local storage_info = recording_utils.storageInfo(ifid) local max_space = recording_utils.recommendedSpace(ifid, storage_info) max_space = math.floor(max_space/(1024*1024*1024))*1024 if isEmptyString(disk_space) then disk_space = max_space end disk_space = tostring(math.floor(tonumber(disk_space)/1024)) print("