Use meaningful names (2)

This commit is contained in:
Alfredo Cardigliano 2023-11-03 10:37:36 +01:00
parent d29c4d384d
commit 628cdac01b

View file

@ -42,12 +42,13 @@ require "lua_utils" -- used by tprint (debug)
local host_to_scan_key = "ntopng.vs.hosts.scanned_values"
local prefs_host_values_key = "ntopng.prefs.vs.hosts_conf"
local host_to_scan_periodicity_key = "ntopng.vs.periodic_scan"
local ondemand_scan_key = "ntopng.vs.scan_all"
local host_scannned_count_key = "ntopng.prefs.host_to_scan.count_scanned"
local host_scan_queue_key = "ntopng.vs.scan_queue"
local periodic_scan_key = "ntopng.vs.periodic_scan"
local periodic_scan_type_key = "ntopng.vs.periodic_scan_type"
local ondemand_scan_key = "ntopng.vs.scan_all"
local scanned_hosts_count_key = "ntopng.prefs.host_to_scan.count_scanned"
local scanned_hosts_changes_key = "ntopng.alerts.scanned_hosts_changes"
local host_in_scanning_hash_key = "ntopng.vs.hosts.in_scanning"
local host_scan_queue_key = "ntopng.vs.scan_queue"
-- redis key for last scan report dates
local hosts_scan_last_report_dates = "ntopng.vs.report_dates"
@ -56,7 +57,7 @@ local hosts_scan_last_report_dates = "ntopng.vs.report_dates"
local periodic_scan_host_info_key = "ntopng.vs.periodic_scan.info"
-- redis keys for scan all info
local ondemand_scan_host_info_key = "ntopng.vs.scan_all.info"
local ondemand_scan_host_info_key = "ntopng.vs.scan_all.info"
local json = require("dkjson")
local format_utils = require("format_utils")
@ -984,7 +985,7 @@ function vs_utils.update_ts_counters()
end
local count = ntop.getCache(host_scannned_count_key)
local count = ntop.getCache(scanned_hosts_count_key)
if (not isEmptyString(count)) then
hosts_scanned = tonumber(count)
end
@ -1143,7 +1144,7 @@ end
-- Function to verify if periodic scan is ended
function vs_utils.is_periodic_scan_completed()
local periodicity_scan_in_progress = ntop.getCache(host_to_scan_periodicity_key) == "1"
local periodicity_scan_in_progress = ntop.getCache(periodic_scan_key) == "1"
if (periodicity_scan_in_progress) then
local hosts_details = vs_utils.retrieve_hosts_to_scan()
@ -1155,9 +1156,9 @@ function vs_utils.is_periodic_scan_completed()
end
end
ntop.setCache(host_to_scan_periodicity_key, "0")
ntop.setCache(periodic_scan_key, "0")
local periodicity = ntop.getCache(host_to_scan_periodicity_key.."type")
local periodicity = ntop.getCache(periodic_scan_type_key)
for _,item in ipairs(hosts_details) do
local host_hash_key = vs_utils.get_host_hash_key(item.host, item.scan_type)
@ -1219,7 +1220,7 @@ end
-- Function to enable periodic scan end check on callbacks
function vs_utils.is_periodic_scan_running()
return ntop.getCache(host_to_scan_periodicity_key) == "1"
return ntop.getCache(periodic_scan_key) == "1"
end
-- **********************************************************
@ -1325,8 +1326,8 @@ function vs_utils.delete_host_to_scan(host, scan_type, all)
ntop.delCache(host_to_scan_key)
ntop.delCache(host_scan_queue_key)
ntop.delCache(host_in_scanning_hash_key)
ntop.delCache(host_to_scan_periodicity_key)
ntop.delCache(host_to_scan_periodicity_key.."type")
ntop.delCache(periodic_scan_key)
ntop.delCache(periodic_scan_type_key)
local path_to_s_result = get_report_path(scan_type, host, true)
os.execute("rm -f "..path_to_s_result)
@ -1496,7 +1497,7 @@ function vs_utils.scan_host(scan_type, host, ports, scan_id, use_coroutines)
if scan_result then
scan_result = vs_utils.scan_status.ok
ntop.incrCache(host_scannned_count_key)
ntop.incrCache(scanned_hosts_count_key)
end
if debug_me then
@ -1585,7 +1586,7 @@ function vs_utils.schedule_periodic_scan(periodicity)
local host_to_scan_list = vs_utils.retrieve_hosts_to_scan()
if (#host_to_scan_list > 0 ) then
local is_already_running = ntop.getCache(host_to_scan_periodicity_key) == "1"
local is_already_running = ntop.getCache(periodic_scan_key) == "1"
if not is_already_running then
local is_scanning_almost_one = false
@ -1601,8 +1602,8 @@ function vs_utils.schedule_periodic_scan(periodicity)
if is_scanning_almost_one then
ntop.setCache(host_to_scan_periodicity_key , "1")
ntop.setCache(host_to_scan_periodicity_key.."type", periodicity)
ntop.setCache(periodic_scan_key , "1")
ntop.setCache(periodic_scan_type_key, periodicity)
ntop.setCache(periodic_scan_host_info_key , json.encode({