Implements flow callbacks and alerts in C++

This commit is contained in:
Simone Mainardi 2021-03-22 09:51:36 +01:00
parent 3659188002
commit aea9138bfb
353 changed files with 10790 additions and 4455 deletions

View file

@ -42,6 +42,28 @@ function flow_pools:get_all_members() return {} end
-- ##############################################
--@brief Tells the C++ core about the flow recipients
function flow_pools:set_flow_recipients(recipients)
-- Create a bitmap of all recipients responsible for flows (pool_id in this case is ignored)
local recipients_bitmap = 0
for _, recipient_id in ipairs(recipients) do
recipients_bitmap = recipients_bitmap | (1 << recipient_id)
end
-- Tell the C++ that flow recipients have changed
ntop.recipient_set_flow_recipients(recipients_bitmap)
end
-- ##############################################
--@brief Method called after a successful execution of method persist
function flow_pools:_post_persist(pool_id, name, members, recipients)
self:set_flow_recipients(recipients)
end
-- ##############################################
function flow_pools:default_only()
-- This is a dummy, default-only pool
return true

View file

@ -239,6 +239,12 @@ function pools:_unlock() ntop.delCache(self:_get_pool_lock_key()) end
-- ##############################################
--@brief Method called after a successful execution of method persist
function pools:_post_persist(pool_id, name, members, recipients)
end
-- ##############################################
-- @brief Persist pool details to disk. Possibly assign a pool id
-- @param pool_id The pool_id of the pool which needs to be persisted. If nil, a new pool id is assigned
function pools:_persist(pool_id, name, members, recipients)
@ -259,6 +265,8 @@ function pools:_persist(pool_id, name, members, recipients)
ntop.setCache(pool_details_key, json.encode(pool_details))
self:_post_persist(pool_id, name, members, recipients)
ntop.reloadPeriodicScripts()
-- Return the assigned pool_id

View file

@ -119,7 +119,7 @@ function pools_alert_utils.get_entity_recipients_by_pool_id(entity_id, pool_id,
end
if recipient_ok then
if recipient["recipient_minimum_severity"] ~= nil and
if alert_severity and recipient["recipient_minimum_severity"] ~= nil and
alert_severity < recipient["recipient_minimum_severity"] then
-- If the current alert severity is less than the minimum requested severity
-- exclude the recipient