Migrates alerts to an object-oriented implementation

This commit is contained in:
Matteo Biscosi 2020-12-23 10:55:53 +01:00
parent f412783c12
commit 101c53336e
30 changed files with 970 additions and 910 deletions

View file

@ -2,36 +2,47 @@
-- (C) 2019-20 - ntop.org
--
local alert_keys = require "alert_keys"
local alert_creators = require "alert_creators"
-- ##############################################
local function formatAlertShellExec(ifid, alert, info)
local alert_keys = require "alert_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_shell_script_executed = classes.class(alert)
-- ##############################################
alert_shell_script_executed.meta = {
alert_key = alert_keys.ntopng.alert_shell_script_executed,
i18n_title = "alerts_dashboard.shell_script",
icon = "fas fa-info-circle",
}
-- ##############################################
function alert_shell_script_executed:init(script_exec_comm, alert_type)
-- Call the paren constructor
self.super:init()
self.alert_type_params = {
script_exec_comm = script_exec_comm,
alert_type = alert_type,
}
end
-- #######################################################
function alert_shell_script_executed.format(ifid, alert, alert_type_params)
return(i18n("alert_messages.shell_script_executed", {
script_exec_comm = info.script_exec_comm,
alert_type = info.alert_type,
script_exec_comm = alert_type_params.script_exec_comm,
alert_type = alert_type_params.alert_type,
}))
end
-- #######################################################
local function createAlertShellExec(alert_severity, script_exec_comm, alert_type)
local shell_script_type = {
alert_severity = alert_severity,
alert_type_params = {
script_exec_comm = script_exec_comm,
alert_type = alert_type,
}
}
return shell_script_type
end
-- #######################################################
return {
alert_key = alert_keys.ntopng.alert_shell_script_executed,
i18n_title = "alerts_dashboard.shell_script",
i18n_description = formatAlertShellExec,
icon = "fas fa-info-circle",
creator = createAlertShellExec
}
return alert_shell_script_executed