mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Implements old aggregated flows cleanup
This commit is contained in:
parent
859284e070
commit
3bedb40a97
1 changed files with 13 additions and 10 deletions
|
|
@ -6,6 +6,7 @@ dirs = ntop.getDirs()
|
|||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
require "flow_aggregation_utils"
|
||||
|
||||
local callback_utils = {}
|
||||
|
||||
|
|
@ -131,17 +132,19 @@ end
|
|||
function callback_utils.harverstExpiredMySQLFlows(ifname, mysql_retention, verbose)
|
||||
interface.select(ifname)
|
||||
|
||||
local sql = "DELETE FROM flowsv4 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)"
|
||||
interface.execSQLQuery(sql)
|
||||
if(verbose) then io.write(sql.."\n") end
|
||||
local dbtables = {"flowsv4", "flowsv6"}
|
||||
if useAggregatedFlows() then
|
||||
dbtables[#dbtables+1] = "aggrflowsv4"
|
||||
dbtables[#dbtables+1] = "aggrflowsv6"
|
||||
end
|
||||
|
||||
sql = "DELETE FROM flowsv6 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)"
|
||||
interface.execSQLQuery(sql)
|
||||
if(verbose) then io.write(sql.."\n") 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
|
||||
|
||||
-- ########################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue