mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Reworks handling of MAC addresses in service and periodicity maps
Addresses #5625
This commit is contained in:
parent
1540d46e7a
commit
68b97e540d
3 changed files with 1 additions and 45 deletions
|
|
@ -10,8 +10,6 @@ local behavior_utils = {}
|
|||
local redis_key = "changed_behavior_learning_setup"
|
||||
local behavior_maps_key = "ntopng.prefs.is_behaviour_analysis_enabled"
|
||||
local behavior_mac_ip_mapping = "ntopng.cache.mac_ip_mapping_ifid"
|
||||
local mac_ip_table = {}
|
||||
local SEC_BEFORE_EXPIRE = 420 -- 7 mins
|
||||
|
||||
-- ##############################################
|
||||
|
||||
|
|
@ -70,7 +68,6 @@ end
|
|||
|
||||
local maps_utils = {}
|
||||
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function areMapsEnabled()
|
||||
|
|
@ -79,40 +76,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function behavior_utils.mapMacIp(hostname, hoststats)
|
||||
local first_host
|
||||
local mac_hosts = interface.getMacHosts(hoststats["mac"])
|
||||
for _, h in pairsByKeys(mac_hosts, asc) do
|
||||
first_host = h["ip"]
|
||||
break
|
||||
end
|
||||
|
||||
mac_ip_table[hoststats["mac"]] = first_host
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function behavior_utils.updateMacs()
|
||||
mac_ip_table = {}
|
||||
callback_utils.foreachLocalHost(interface.getName(), behavior_utils.mapMacIp)
|
||||
ntop.setCache(behavior_mac_ip_mapping .. interface.getId(), json.encode(mac_ip_table), SEC_BEFORE_EXPIRE)
|
||||
return mac_ip_table
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function behavior_utils.getMacs()
|
||||
mac_ip_table = ntop.getCache(behavior_mac_ip_mapping .. interface.getId())
|
||||
|
||||
if not isEmptyString(mac_ip_table) then
|
||||
return json.decode(mac_ip_table)
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- Returns two bools value, one for service map and the other for periodicity map
|
||||
function behavior_utils.mapsAvailable()
|
||||
local service_map_available = false
|
||||
|
|
@ -136,4 +99,4 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
return behavior_utils
|
||||
return behavior_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue