mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Add more recipient stats for all endpoints
This commit is contained in:
parent
cc71465273
commit
4963dddfbf
21 changed files with 367 additions and 73 deletions
|
|
@ -119,12 +119,18 @@ end
|
|||
function webhook.dequeueRecipientAlerts(recipient, budget)
|
||||
local start_time = os.time()
|
||||
local sent = 0
|
||||
local more_available = true
|
||||
local budget_used = 0
|
||||
local num_messages_dequeued = 0
|
||||
local debugme = false
|
||||
local settings = recipient2sendMessageSettings(recipient)
|
||||
|
||||
local more_available = true
|
||||
local success = true
|
||||
local error_message = nil
|
||||
local delivered = 0
|
||||
local discarded = 0
|
||||
local failures = 0
|
||||
|
||||
-- Dequeue alerts up to budget x MAX_ALERTS_PER_REQUEST
|
||||
-- Note: in this case budget is the number of webhook messages to send
|
||||
while budget_used <= budget and more_available do
|
||||
|
|
@ -142,6 +148,8 @@ function webhook.dequeueRecipientAlerts(recipient, budget)
|
|||
if alert_utils.filter_notification(notification, recipient.recipient_id) then
|
||||
notifications[#notifications + 1] = notification.alert
|
||||
i = i + 1
|
||||
else
|
||||
discarded = discarded + 1
|
||||
end
|
||||
else
|
||||
break
|
||||
|
|
@ -167,9 +175,13 @@ function webhook.dequeueRecipientAlerts(recipient, budget)
|
|||
|
||||
if not webhook.sendMessage(alerts, settings) then
|
||||
if(debugme) then tprint("[FAILURE] Message delivery failed") end
|
||||
return { success = false, error_message = "Unable to send alerts to the webhook" }
|
||||
success = false
|
||||
error_message = "Unable to send alerts to the webhook"
|
||||
failures = failures + #notifications
|
||||
goto done
|
||||
else
|
||||
if(debugme) then tprint("[OK] Message sent correctly") end
|
||||
delivered = delivered + #notifications
|
||||
end
|
||||
|
||||
-- Remove the processed messages from the queue
|
||||
|
|
@ -178,8 +190,16 @@ function webhook.dequeueRecipientAlerts(recipient, budget)
|
|||
end
|
||||
|
||||
if(debugme) then tprint("[END] Sent "..num_messages_dequeued.." messages") end
|
||||
|
||||
return { success = true, more_available = more_available }
|
||||
|
||||
::done::
|
||||
return {
|
||||
success = success,
|
||||
error_message = error_message,
|
||||
delivered = delivered,
|
||||
discarded = discarded,
|
||||
failures = failures,
|
||||
more_available = more_available,
|
||||
}
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue