mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Alerts are no longer enqueued if disabled
This commit is contained in:
parent
09eb53a16d
commit
f038baf804
2 changed files with 24 additions and 13 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue