diff --git a/scripts/lua/modules/alert_consts.lua b/scripts/lua/modules/alert_consts.lua index 8daf8bbbe2..16e07fbeff 100644 --- a/scripts/lua/modules/alert_consts.lua +++ b/scripts/lua/modules/alert_consts.lua @@ -355,7 +355,7 @@ local function loadAlertsDefs() goto next_script end - if not alert_consts.loadDefinition(def_script, mod_fname, defs_dir) then + if not loadDefinition(def_script, mod_fname, defs_dir) then -- Retry reload package.loaded[mod_fname] = nil end @@ -375,28 +375,26 @@ end -- ############################################## -function alert_consts.loadDefinition(def_script, mod_fname, script_path) +function loadDefinition(def_script, mod_fname, script_path) local required_fields = {"alert_key", "i18n_title", "icon"} -- Check the required fields for _, k in pairs(required_fields) do if(def_script[k] == nil) then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing required field '%s' in %s", k, script_path)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing required field '%s' in %s from %s", k, mod_fname, script_path)) return(false) end end -- Sanity check: make sure this is a valid alert key local parsed_alert_key, status = alert_keys.parse_alert_key(def_script.alert_key) - if not parsed_alert_key then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("%s: invalid alert key specified: %s", - script_path, status)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Invalid alert key specified %s in %s from %s", status, mod_fname, script_path)) return(false) end if(alerts_by_id[parsed_alert_key] ~= nil) then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("%s: alert key %d redefined, skipping", script_path, parsed_alert_key)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Alert key %d redefined, skipping in %s from %s", parsed_alert_key, mod_fname, script_path)) return(false) end diff --git a/scripts/lua/modules/alert_definitions/alert_flow_blacklisted.lua b/scripts/lua/modules/alert_definitions/alert_flow_blacklisted.lua deleted file mode 100644 index ea5dd34af0..0000000000 --- a/scripts/lua/modules/alert_definitions/alert_flow_blacklisted.lua +++ /dev/null @@ -1,29 +0,0 @@ --- --- (C) 2019-20 - ntop.org --- - --- ####################################################### - --- @brief Prepare an alert table used to generate the alert --- @param alert_severity A severity as defined in `alert_consts.alert_severities` --- @param info A flow info table fetched with `flow.getBlacklistedInfo()` --- @return A table with the alert built -local function createBlacklisted(alert_severity, info) - local built = { - alert_severity = alert_severity, - alert_type_params = info, - } - - return built -end - --- ####################################################### - -local alert_keys = require "alert_keys" - -return { - alert_key = alert_keys.ntopng.alert_flow_blacklisted, - i18n_title = "alerts_dashboard.blacklisted_flow", - icon = "fas fa-exclamation", - creator = createBlacklisted, -} diff --git a/scripts/lua/modules/flow_consts.lua b/scripts/lua/modules/flow_consts.lua index a6522f9f3c..610eeeaa1c 100644 --- a/scripts/lua/modules/flow_consts.lua +++ b/scripts/lua/modules/flow_consts.lua @@ -58,7 +58,7 @@ local function loadStatusDefs() goto next_script end - if not flow_consts.loadDefinition(def_script, mod_fname, defs_dir) then + if not loadDefinition(def_script, mod_fname, defs_dir) then -- Retry reload package.loaded[mod_fname] = nil end @@ -79,7 +79,7 @@ end -- ################################################################################ -function flow_consts.loadDefinition(def_script, mod_fname, script_path) +function loadDefinition(def_script, mod_fname, script_path) local required_fields = {"status_key", "alert_severity", "alert_type", "i18n_title"} -- print("Loading "..script_path.."\n") @@ -87,7 +87,7 @@ function flow_consts.loadDefinition(def_script, mod_fname, script_path) -- Check the required fields for _, k in pairs(required_fields) do if(def_script[k] == nil) then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing required field '%s' in %s", k, script_path)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing required field '%s' in %s from %s", k, mod_fname, script_path)) return(false) end end @@ -95,7 +95,7 @@ function flow_consts.loadDefinition(def_script, mod_fname, script_path) local def_id = def_script.status_key if(def_id == nil) then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("%s: missing status ID", script_path)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing status ID in %s from %s", mod_fname, script_path)) return(false) end @@ -111,12 +111,12 @@ function flow_consts.loadDefinition(def_script, mod_fname, script_path) end if not valid then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("%s: invalid status ID", script_path)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Invalid status ID in %s from %s", mod_fname, script_path)) return(false) end if(status_by_id[def_id] ~= nil) then - traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("%s: status ID %d redefined, skipping", script_path, def_id)) + traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Status ID %d redefined, skipping in %s from %s", def_id, mod_fname, script_path)) return(false) end