Implements periodic alerts rotation

Oldest alerts are periodically overwritten by newest ones
when a certain (user-configurable) threshold has been exceeded.
Rotation is performed periodically in a housekeeping.lua
This commit is contained in:
Simone Mainardi 2017-01-17 15:15:23 +01:00
parent 107b4543a5
commit e8cffe9227
7 changed files with 96 additions and 11 deletions

View file

@ -123,6 +123,10 @@ function get_re_arm_alerts_hash_name()
return "ntopng.prefs.alerts_re_arm_minutes"
end
function get_housekeeping_set_name(ifId)
return "ntopng.alerts.ifid_"..ifId..".make_room"
end
function get_re_arm_alerts_hash_key(ifid, ifname_or_network)
local parts = {"ifid", tostring(ifid)}
if ifname_or_network ~= nil then
@ -1205,6 +1209,30 @@ end
-- #################################
function housekeepingAlertsMakeRoom()
local ifnames = interface.getIfNames()
for id, n in pairs(ifnames) do
interface.select(n)
local ifId = getInterfaceId(n)
local k = get_housekeeping_set_name(ifId)
local members = ntop.getMembersCache(k)
for _, m in pairs(members) do
ntop.delMembersCache(k, m)
m = m:split("|")
local alert_entity = tonumber(m[1])
local alert_entity_value = m[2]
local table_name = m[3]
interface.makeRoomAlerts(alert_entity, alert_entity_value, table_name)
end
end
end
-- #################################
function drawAlertTables(num_past_alerts, num_engaged_alerts, num_flow_alerts, get_params, hide_extended_title, alt_nav_tabs)
local alert_items = {}
local url_params = {}