mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Match AM notifications against Host Pools
This commit is contained in:
parent
70831b9e01
commit
6886186418
4 changed files with 60 additions and 59 deletions
|
|
@ -13,6 +13,7 @@ local alert_severities = require "alert_severities"
|
|||
local alert_consts = require("alert_consts")
|
||||
local os_utils = require("os_utils")
|
||||
local recipients = require "recipients"
|
||||
local pools_alert_utils = require "pools_alert_utils"
|
||||
local do_trace = false
|
||||
|
||||
local alerts_api = {}
|
||||
|
|
@ -129,11 +130,8 @@ end
|
|||
--! @brief Adds pool information to the alert
|
||||
--! @param entity_info data returned by one of the entity_info building functions
|
||||
local function addAlertPoolInfo(entity_info, alert_json)
|
||||
local pools_alert_utils = require "pools_alert_utils"
|
||||
|
||||
if alert_json then
|
||||
local pool_id = pools_alert_utils.get_entity_pool_id(entity_info)
|
||||
alert_json.pool_id = pool_id
|
||||
alert_json.host_pool_id = pools_alert_utils.get_host_pool_id(entity_info)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -181,7 +179,6 @@ function alerts_api.store(entity_info, type_info, when)
|
|||
}
|
||||
|
||||
addAlertPoolInfo(entity_info, alert_to_store)
|
||||
|
||||
recipients.dispatch_notification(alert_to_store, current_script)
|
||||
|
||||
return(true)
|
||||
|
|
@ -269,6 +266,7 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts)
|
|||
end
|
||||
|
||||
local alert_json = json.encode(type_info.alert_type_params)
|
||||
|
||||
local triggered
|
||||
local alert_key_name = get_alert_triggered_key(type_info.alert_type.alert_key, subtype)
|
||||
|
||||
|
|
@ -308,14 +306,13 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts)
|
|||
triggered.ifid = ifid
|
||||
triggered.action = "engage"
|
||||
|
||||
addAlertPoolInfo(entity_info, triggered)
|
||||
|
||||
-- Emit the notification only if the notification hasn't already been emitted.
|
||||
-- This is to avoid alert storms when ntopng is restarted. Indeeed,
|
||||
-- if there are 100 alerts triggered when ntopng is switched off, chances are the
|
||||
-- same 100 alerts will be triggered again as soon as ntopng is restarted, causing
|
||||
-- 100 trigger notifications to be emitted twice. This check is to prevent such behavior.
|
||||
if not is_trigger_notified(triggered) then
|
||||
addAlertPoolInfo(entity_info, triggered)
|
||||
recipients.dispatch_notification(triggered, current_script)
|
||||
mark_trigger_notified(triggered)
|
||||
end
|
||||
|
|
@ -388,9 +385,7 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts)
|
|||
released.action = "release"
|
||||
|
||||
addAlertPoolInfo(entity_info, released)
|
||||
|
||||
mark_release_notified(released)
|
||||
|
||||
recipients.dispatch_notification(released, current_script)
|
||||
|
||||
return(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue