Add update all periodicity scan button. (#7744)

This commit is contained in:
Nicolo Maio 2023-08-09 13:29:22 +02:00
parent c77b1df2f3
commit 869981544b
7 changed files with 153 additions and 7 deletions

View file

@ -302,6 +302,8 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
if not isEmptyString(scan_frequency) then
new_item.scan_frequency = scan_frequency
elseif old_data and not isEmptyString(old_data.scan_frequency) then
new_item.scan_frequency = old_data.scan_frequency
end
if(scan_result ~= nil) then
@ -589,4 +591,25 @@ end
-- **********************************************************
-- Update all scan frequencies
function vs_utils.update_all_periodicity(scan_frequency)
local host_to_scan_list = vs_utils.retrieve_hosts_to_scan()
for _,value in ipairs(host_to_scan_list) do
local host_hash_key = vs_utils.get_host_hash_key(value.host, value.scan_type)
local host_hash_value_string = ntop.getHashCache(host_to_scan_key, host_hash_key)
if(not isEmptyString(host_hash_value_string)) then
local host_hash_value = json.decode(host_hash_value_string)
host_hash_value.scan_frequency = scan_frequency
ntop.setHashCache(host_to_scan_key, host_hash_key, json.encode(host_hash_value))
end
end
return true
end
-- **********************************************************
return vs_utils