Code review and cleanup

This commit is contained in:
Alfredo Cardigliano 2023-07-21 16:54:48 +02:00
parent 392ce43159
commit c5e0107c4a
7 changed files with 80 additions and 87 deletions

View file

@ -12,7 +12,6 @@ local alert_utils = require "alert_utils"
local endpoint_key = "shell"
local shell = {
name = "Shell Script",
endpoint_params = {
@ -78,8 +77,8 @@ function shell.runScript(alerts, settings)
if(do_debug) then tprint("Checking "..path) end
if(ntop.exists(path)) then
fullpath = path
break
fullpath = path
break
end
end
@ -142,16 +141,15 @@ function shell.dequeueRecipientAlerts(recipient, budget)
local notifications = {}
local i = 0
while i < MAX_ALERTS_PER_REQUEST do
local notification = ntop.recipient_dequeue(recipient.recipient_id)
if notification then
if alert_utils.filter_notification(notification, recipient.recipient_id) then
notifications[#notifications + 1] = notification.alert
i = i + 1
end
else
break
end
local notification = ntop.recipient_dequeue(recipient.recipient_id)
if notification then
if alert_utils.filter_notification(notification, recipient.recipient_id) then
notifications[#notifications + 1] = notification.alert
i = i + 1
end
else
break
end
end
if not notifications or #notifications == 0 then
@ -167,7 +165,7 @@ function shell.dequeueRecipientAlerts(recipient, budget)
end
if(shell.runScript(alerts, settings) == false) then
return { success=false, error_message="- unable to execute the script" }
return { success=false, error_message="- unable to execute the script" }
end
-- Remove the processed messages from the queue