mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Reduce llen number of calls for alerts queue rating
This commit is contained in:
parent
7a637ab9d7
commit
23e427e361
1 changed files with 12 additions and 1 deletions
|
|
@ -64,8 +64,8 @@ end
|
|||
-- @param ref_limit the maximum queue size
|
||||
-- @param inc_drops true if alert drops should be incremented
|
||||
local function enqueueAlertEvent(queue, event, ref_limit, inc_drops)
|
||||
local num_pending = ntop.llenCache(queue)
|
||||
local queue_rating_key = string.format("%s.rating", queue)
|
||||
local queue_len_key = string.format("%s.len", queue)
|
||||
local cur_status = ntop.getCache(queue_rating_key)
|
||||
local rv
|
||||
|
||||
|
|
@ -74,6 +74,14 @@ local function enqueueAlertEvent(queue, event, ref_limit, inc_drops)
|
|||
local high_value = math.ceil(ref_limit / 2)
|
||||
local trim_limit = ref_limit
|
||||
|
||||
-- NOTE: using a cached value to avoid calling llenCache every time
|
||||
local num_pending = tonumber(ntop.getCache(queue_len_key))
|
||||
|
||||
if(num_pending == nil) then
|
||||
num_pending = ntop.llenCache(queue)
|
||||
ntop.setCache(queue_len_key, string.format("%d", num_pending), 2 --[[ recheck every 2 seconds ]])
|
||||
end
|
||||
|
||||
-- The rpush is only performed in "normal" status
|
||||
if isEmptyString(cur_status) then
|
||||
cur_status = "normal"
|
||||
|
|
@ -106,6 +114,9 @@ local function enqueueAlertEvent(queue, event, ref_limit, inc_drops)
|
|||
if(inc_drops) then
|
||||
interface.incNumDroppedAlerts(num_drop)
|
||||
end
|
||||
|
||||
-- Recalculate num_pending on next round
|
||||
ntop.delCache(queue_len_key)
|
||||
end
|
||||
|
||||
if(cur_status == "full") then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue