mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +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
|
|
@ -129,6 +129,12 @@ function discord.dequeueRecipientAlerts(recipient, budget)
|
|||
local settings = readSettings(recipient)
|
||||
local max_alerts_per_request = 1 -- collapse up to X alerts per request
|
||||
|
||||
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 email to send
|
||||
while budget_used <= budget and more_available do
|
||||
|
|
@ -146,6 +152,8 @@ function discord.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
|
||||
|
|
@ -165,7 +173,12 @@ function discord.dequeueRecipientAlerts(recipient, budget)
|
|||
|
||||
local res, msg = discord.sendMessage(table.concat(alerts, "\n"), settings)
|
||||
if not res then
|
||||
return {success = false, error_message = msg or "Unable to send alerts to Discord"}
|
||||
success = false
|
||||
error_message = msg or "Unable to send alerts to Discord"
|
||||
failures = failures + #notifications
|
||||
goto done
|
||||
else
|
||||
delivered = delivered + #notifications
|
||||
end
|
||||
|
||||
-- Remove the processed messages from the queue
|
||||
|
|
@ -173,7 +186,15 @@ function discord.dequeueRecipientAlerts(recipient, budget)
|
|||
sent = sent + 1
|
||||
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