Stores integer interface ids into MySQL

Interface flows are now stored using integer interface ids rather
than interface names. This speeds up queries.
A migration code has also been introduced so that old MySQL table
format is migrated and old data does not get lost.

This also fixes #460
This commit is contained in:
Simone Mainardi 2016-03-25 19:58:00 +01:00
parent 426ebc0c0e
commit 2754c2dfa1
4 changed files with 70 additions and 24 deletions

View file

@ -46,7 +46,7 @@ function top_peers_query(interface_id, version, host, protocol, port, l7proto, i
sql = sql.." WHERE FIRST_SWITCHED <= "..end_epoch.." and FIRST_SWITCHED >= "..begin_epoch
sql = sql.." AND (NTOPNG_INSTANCE_NAME='"..ntop.getPrefs()["instance_name"].."'OR NTOPNG_INSTANCE_NAME IS NULL)"
sql = sql.." AND (INTERFACE='"..getInterfaceName(interface_id).."' OR INTERFACE IS NULL)"
sql = sql.." AND (INTERFACE_ID='"..tonumber(interface_id).."')"
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