Added in preferences the ability to specify the MySQL data retention

This commit is contained in:
Luca Deri 2015-09-22 23:32:39 +02:00
parent a62344d45c
commit 2767caa991
4 changed files with 43 additions and 11 deletions

View file

@ -7,7 +7,7 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "template"
local db_debug = false
local db_debug = true
--- ====================================================================
@ -106,12 +106,13 @@ end
--- ====================================================================
function getNumFlows(interface_id, version, host, protocol, port, l7proto, begin_epoch, end_epoch)
function getNumFlows(interface_id, version, host, protocol, port, l7proto, info, begin_epoch, end_epoch)
if(version == nil) then version = 4 end
sql = "select COUNT(*) AS TOT_FLOWS, SUM(BYTES) AS TOT_BYTES, SUM(PACKETS) AS TOT_PACKETS FROM flowsv"..version.."_"..interface_id.." where FIRST_SWITCHED <= "..end_epoch.." and FIRST_SWITCHED >= "..begin_epoch
if((l7proto ~= nil) and (l7proto ~= "")) then sql = sql .." AND L7_PROTO="..l7proto end
if((protocol ~= nil) and (protocol ~= "")) then sql = sql .." AND PROTOCOL="..protocol end
if(info ~= "") then sql = sql .." AND (INFO='"..info.."')" end
if((port ~= nil) and (port ~= "")) then sql = sql .." AND (L4_SRC_PORT="..port.." OR L4_DST_PORT="..port..")" end