mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Implements stateful alerts in C and sqlite
This commit is contained in:
parent
781b3d4988
commit
12f24a87b4
11 changed files with 425 additions and 214 deletions
|
|
@ -104,43 +104,3 @@ function forge_alert(alert, alert_severity, alert_type, alert_msg, close)
|
|||
return alert_j
|
||||
end
|
||||
|
||||
function alert_move_ongoing_to_closed(ifid, ongoing_hname, ongoing_hkey)
|
||||
local ongoing_value = ntop.getHashCache(ongoing_hname, ongoing_hkey)
|
||||
|
||||
local alert = {}
|
||||
if ongoing_value == "" or ongoing_value == nil then
|
||||
return false -- cannot withdraw an alert that was not ongoing
|
||||
else
|
||||
alert = ongoing_value
|
||||
end
|
||||
|
||||
-- remove the alert from the active queue
|
||||
ntop.delHashCache(ongoing_hname, ongoing_hkey)
|
||||
-- and move it to the closed list
|
||||
alert = forge_alert(alert, nil, nil, nil, os.time())
|
||||
|
||||
interface.storeAlert(ifid, alert)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function delete_stateful_alert_configuration(alert_source, ifname)
|
||||
local ifid = getInterfaceId(ifname)
|
||||
-- check if we are processing a pair ip-vlan such as 192.168.1.0@0
|
||||
if string.match(alert_source, "@") then
|
||||
local host_info = hostkey2hostinfo(alert_source)
|
||||
local host_ip = host_info["host"]
|
||||
local host_vlan = host_info["vlan"]
|
||||
local ongoing_hname = get_host_ongoing_hash_name(ifid, host_ip, host_vlan)
|
||||
local ongoing_alerts = ntop.getHashKeysCache(ongoing_hname)
|
||||
|
||||
-- move the ongoing alerts to the closed list
|
||||
if type(ongoing_alerts) ~= "table" then ongoing_alerts = {} end
|
||||
for alertk, _ in pairs(ongoing_alerts) do
|
||||
alert_move_ongoing_to_closed(ifid, ongoing_hname, alertk)
|
||||
end
|
||||
else
|
||||
local check = "TODO"
|
||||
-- check if is an interface or a network
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue