Reworks MySQL structure and adds interface support to dumped flows

Existing MySQL naming convention makes two separate tables for each interface monitored. Table names are flows4_<ifid> and flows6_<ifid>. Ifid is a unique integer identifier chosen by ntopng.

Present commit simplifies this structure and make just two tables, namely flows4 and flows6, and add an extra column to store the interface names. I do not think that storing the integer interface id is good: it is just a number that only make sense inside ntopng. Using interface names would yield more (re)usable data.

Committed code transparently migrates old tables into the new ones. Old flows are migrated into the new tables, and old tables are dropped.
This commit is contained in:
Simone Mainardi 2015-12-07 17:20:12 +01:00
parent 6fe11c37c0
commit 0c92e286d4
2 changed files with 106 additions and 32 deletions

View file

@ -46,7 +46,7 @@ function getInterfaceTopFlows(interface_id, version, host_or_profile, l7proto, l
follow = " ,L4_SRC_PORT,L4_DST_PORT,VLAN_ID,PROTOCOL,FIRST_SWITCHED,LAST_SWITCHED,PACKETS,BYTES,idx,L7_PROTO,INFO"
if ntop.isPro() then follow = follow..",PROFILE" end
follow = follow.." from flowsv"..version.."_"..interface_id.." where FIRST_SWITCHED <= "..end_epoch.." and FIRST_SWITCHED >= "..begin_epoch
follow = follow.." from flowsv"..version.." where FIRST_SWITCHED <= "..end_epoch.." and FIRST_SWITCHED >= "..begin_epoch
if((l7proto ~= "") and (l7proto ~= "-1")) then follow = follow .." AND L7_PROTO="..l7proto end
if((l4proto ~= "") and (l4proto ~= "-1")) then follow = follow .." AND PROTOCOL="..l4proto end