mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Removes intermediate alert queues - only leaves recipient queues
Implements #4366
This commit is contained in:
parent
9fe21dac15
commit
85f555a908
14 changed files with 110 additions and 191 deletions
|
|
@ -2221,68 +2221,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- Check for alerts in the notification queue and process them.
|
||||
-- NOTE: this is executed in a system VM, with no interfaces references
|
||||
function alert_utils.processAlertNotifications(now, periodic_frequency, force_export)
|
||||
if(not areAlertsEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Process existing notifications BEFORE possibly dispatching new notifications.
|
||||
-- This prevents dispatching from jeopardizing all the available time, thus preventing
|
||||
-- the actual processing from being performed.
|
||||
notification_recipients.processNotifications(now, periodic_frequency)
|
||||
|
||||
local interfaces = interface.getIfNames()
|
||||
-- max number of alerts per run (this to guarantee fairness and void monopolizing the CPU)
|
||||
-- Set a value such that at 1000 alerts are processed for every second of periodic frequency
|
||||
local budget = periodic_frequency * 1000
|
||||
|
||||
-- Get new alerts
|
||||
while budget > 0 and not ntop.isDeadlineApproaching() do
|
||||
local json_message = ntop.popAlertNotification()
|
||||
|
||||
if((json_message == nil) or (json_message == "")) then
|
||||
break
|
||||
end
|
||||
|
||||
if(verbose) then
|
||||
io.write("Alert Notification: " .. json_message .. "\n")
|
||||
end
|
||||
|
||||
budget = budget - 1
|
||||
|
||||
local message = json.decode(json_message)
|
||||
|
||||
if(not message) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local str_ifid = tostring(message.ifid)
|
||||
|
||||
if((interfaces[str_ifid] == nil) and (str_ifid ~= getSystemInterfaceId())) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
interface.select(str_ifid)
|
||||
|
||||
if message.is_flow_alert then
|
||||
-- Silly but necessary due to the notifyFlowAlert
|
||||
message.alert_entity = alert_consts.alert_entities.flow.entity_id
|
||||
message.alert_entity_val = "flow"
|
||||
message.action = nil
|
||||
|
||||
json_message = json.encode(message)
|
||||
end
|
||||
|
||||
notification_recipients.dispatchNotification(message, json_message)
|
||||
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function notify_ntopng_status(started)
|
||||
local info = ntop.getInfo()
|
||||
local severity = alert_consts.alertSeverity("info")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue