Greatly reduces the number of open files in second.lua

This commit is contained in:
Simone Mainardi 2017-11-23 15:51:12 +01:00
parent 83a58ad016
commit 46439a8c02
5 changed files with 49 additions and 31 deletions

View file

@ -5,8 +5,6 @@
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "flow_aggregation_utils"
local os_utils = require "os_utils"
local callback_utils = {}
@ -175,26 +173,6 @@ end
-- ########################################################
function callback_utils.harverstExpiredMySQLFlows(ifname, mysql_retention, verbose)
interface.select(ifname)
local dbtables = {"flowsv4", "flowsv6"}
if useAggregatedFlows() then
dbtables[#dbtables+1] = "aggrflowsv4"
dbtables[#dbtables+1] = "aggrflowsv6"
end
for _, tb in pairs(dbtables) do
local sql = "DELETE FROM "..tb.." where FIRST_SWITCHED < "..mysql_retention
sql = sql.." AND (INTERFACE_ID = "..getInterfaceId(ifname)..")"
sql = sql.." AND (NTOPNG_INSTANCE_NAME='"..ntop.getPrefs()["instance_name"].."' OR NTOPNG_INSTANCE_NAME IS NULL OR NTOPNG_INSTANCE_NAME='')"
interface.execSQLQuery(sql)
if(verbose) then io.write(sql.."\n") end
end
end
-- ########################################################
function callback_utils.harverstOldRRDFiles(ifname)
-- currently this is only implemented for old devices files. It should actually be implemented for other rrds as well
local rrd_max_days = ntop.getPref("ntopng.prefs.rrd_files_retention")