mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
parent
b7bdd1edaf
commit
dac9b41a98
2 changed files with 0 additions and 90 deletions
|
|
@ -682,95 +682,6 @@ function alerts_api.category_bytes(info, category_name)
|
|||
return curr_val
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
-- ENTITY DISABLED ALERTS API
|
||||
-- ##############################################
|
||||
|
||||
local function getEntityDisabledAlertsBitmapHash(ifid, entity_type)
|
||||
-- NOTE: should be able to accept strings for alerts_api.purgeAlertsPrefs
|
||||
if(type(ifid) == "number") then ifid = string.format("%d", ifid) end
|
||||
if(type(entity_type) == "number") then entity_type = string.format("%u", entity_type) end
|
||||
|
||||
return string.format("ntopng.prefs.alerts.ifid_%s.disabled_alerts.entity_%s", ifid, entity_type)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- A cache variable to know if there are configured disabled alerts
|
||||
local function getInterfaceHasDisabledAlertsKey(ifid)
|
||||
-- NOTE: should be able to accept strings for alerts_api.purgeAlertsPrefs
|
||||
if(type(ifid) == "number") then ifid = string.format("%d", ifid) end
|
||||
|
||||
return(string.format("ntopng.cache.alerts.ifid_%s.has_disabled_alerts", ifid))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Set the disabled alerts bitmap for the given alertable entity
|
||||
function alerts_api.setEntityAlertsDisabledBitmap(ifid, entity_type, entity_val, bitmap)
|
||||
local hash = getEntityDisabledAlertsBitmapHash(ifid, entity_type)
|
||||
|
||||
if(bitmap == 0) then
|
||||
-- No status disabled
|
||||
ntop.delHashCache(hash, entity_val)
|
||||
else
|
||||
ntop.setHashCache(hash, entity_val, string.format("%u", bitmap))
|
||||
end
|
||||
|
||||
-- Invalidate the disabled alerts cache
|
||||
ntop.delCache(getInterfaceHasDisabledAlertsKey(ifid))
|
||||
|
||||
-- Reload the periodic scripts as the configuration has changed
|
||||
ntop.reloadPeriodicScripts()
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Get all the disabled alerts by entity
|
||||
-- @return {entity_type -> {entity_val1 -> bitmap, entity_val2 -> bitmap, ...}, ...}
|
||||
function alerts_api.getAllEntitiesDisabledAlerts(ifid)
|
||||
local available_entities = alert_consts.alert_entities
|
||||
local res = {}
|
||||
|
||||
for entity_key, entity in pairs(available_entities) do
|
||||
local hash = getEntityDisabledAlertsBitmapHash(ifid, entity.entity_id)
|
||||
local entities_bitmaps = ntop.getHashAllCache(hash) or {}
|
||||
local is_empty = true
|
||||
|
||||
for k, v in pairs(entities_bitmaps) do
|
||||
entities_bitmaps[k] = tonumber(v)
|
||||
is_empty = false
|
||||
end
|
||||
|
||||
if(not is_empty) then
|
||||
res[entity_key] = entities_bitmaps
|
||||
end
|
||||
end
|
||||
|
||||
return(res)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
-- HOST DISABLED FLOW STATUS API
|
||||
-- ##############################################
|
||||
|
||||
local function getHostDisabledStatusBitmapHash(ifid)
|
||||
-- NOTE: should be able to accept strings for alerts_api.purgeAlertsPrefs
|
||||
if(type(ifid) == "number") then ifid = string.format("%d", ifid) end
|
||||
|
||||
return(string.format("ntopng.prefs.alerts.ifid_%s.disabled_status", ifid))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Purge all the alerts prefs set by this module
|
||||
function alerts_api.purgeAlertsPrefs()
|
||||
-- Purge all the alerts prefs on all the interfaces
|
||||
deleteCachePattern(getEntityDisabledAlertsBitmapHash("*", "*"))
|
||||
deleteCachePattern(getInterfaceHasDisabledAlertsKey("*"))
|
||||
deleteCachePattern(getHostDisabledStatusBitmapHash("*"))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function alerts_api.invokeScriptHook(user_script, configset_id, hook_fn, p1, p2, p3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue