diff --git a/scripts/callbacks/interface/flow.lua b/scripts/callbacks/interface/flow.lua index 87b6021de1..ac9f4d22fd 100644 --- a/scripts/callbacks/interface/flow.lua +++ b/scripts/callbacks/interface/flow.lua @@ -236,6 +236,11 @@ end -- ################################################################# local function triggerFlowAlert(now, l4_proto) + + if not areAlertsEnabled() then + return(false) + end + local cli_key = flow.getClientKey() local srv_key = flow.getServerKey() local cli_disabled_status = hosts_disabled_status[cli_key] or 0 @@ -436,7 +441,10 @@ local function call_modules(l4_proto, master_id, app_id, mod_fn, update_ctr) -- Only trigger the alert if its score is greater than the currently -- triggered alert score - if alerted_status and (alerted_status_score > flow.getAlertedStatusScore()) then + if areAlertsEnabled() and + alerted_status and + (alerted_status_score > flow.getAlertedStatusScore()) then + triggerFlowAlert(now, l4_proto) if calculate_stats then diff --git a/scripts/lua/modules/alerts_api.lua b/scripts/lua/modules/alerts_api.lua index c11882d260..97f15ef5ad 100644 --- a/scripts/lua/modules/alerts_api.lua +++ b/scripts/lua/modules/alerts_api.lua @@ -137,6 +137,11 @@ end --! @param when (optional) the time when the release event occurs --! @return true if the alert was successfully stored, false otherwise function alerts_api.store(entity_info, type_info, when) + + if(not areAlertsEnabled()) then + return(false) + end + local force = false local ifid = interface.getId() local granularity_sec = type_info.alert_granularity and type_info.alert_granularity.granularity_seconds or 0 @@ -150,10 +155,6 @@ function alerts_api.store(entity_info, type_info, when) local subtype = type_info.alert_subtype or "" when = when or os.time() - if(not areAlertsEnabled()) then - return(false) - end - if alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_key) then return(false) end @@ -243,6 +244,11 @@ end --! @note The actual trigger is performed asynchronously --! @note false is also returned if an existing alert is found and refreshed function alerts_api.trigger(entity_info, type_info, when, cur_alerts) + + if(not areAlertsEnabled()) then + return(false) + end + local ifid = interface.getId() local is_disabled = alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_key) @@ -252,10 +258,6 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts) return(true) end - if(not areAlertsEnabled()) then - return(false) - end - if(type_info.alert_granularity == nil) then alertErrorTraceback("Missing mandatory 'alert_granularity'") return(false) @@ -328,6 +330,11 @@ end --! @note The actual release is performed asynchronously --! @return true on success, false otherwise function alerts_api.release(entity_info, type_info, when, cur_alerts) + + if(not areAlertsEnabled()) then + return(false) + end + -- Apply defaults local granularity_sec = type_info.alert_granularity and type_info.alert_granularity.granularity_seconds or 0 local granularity_id = type_info.alert_granularity and type_info.alert_granularity.granularity_id or 0 --[[ 0 is aperiodic ]] @@ -344,10 +351,6 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts) local params = {alert_key_name, granularity_id, when} local released = nil - if(not areAlertsEnabled()) then - return(false) - end - if(type_info.alert_severity == nil) then alertErrorTraceback(string.format("Missing alert_severity [type=%s]", type_info.alert_type and type_info.alert_type.alert_key or "")) return(false)