mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
Migrates alerts to an object-oriented implementation
This commit is contained in:
parent
c1a7ff08ae
commit
fbc283f12f
108 changed files with 2793 additions and 1737 deletions
|
|
@ -1,34 +1,54 @@
|
|||
--
|
||||
-- (C) 2020 - ntop.org
|
||||
-- (C) 2019-20 - ntop.org
|
||||
--
|
||||
|
||||
local alert_keys = require "alert_keys"
|
||||
local alert_creators = require "alert_creators"
|
||||
|
||||
-- #######################################################
|
||||
|
||||
local function noIfActivity(ifid, alert, no_if_activity_ctrs)
|
||||
return(i18n("no_if_activity.status_no_activity_description"))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function createNoIfActivity(alert_severity, alert_granularity)
|
||||
local no_if_activity_type = {
|
||||
alert_granularity = alert_granularity,
|
||||
alert_severity = alert_severity,
|
||||
alert_type_params = {}
|
||||
}
|
||||
local alert_keys = require "alert_keys"
|
||||
-- Import the classes library.
|
||||
local classes = require "classes"
|
||||
-- Make sure to import the Superclass!
|
||||
local alert = require "alert"
|
||||
|
||||
return no_if_activity_type
|
||||
-- ##############################################
|
||||
|
||||
local alert_no_if_activity = classes.class(alert)
|
||||
|
||||
-- ##############################################
|
||||
|
||||
alert_no_if_activity.meta = {
|
||||
alert_key = alert_keys.ntopng.alert_no_if_activity,
|
||||
i18n_title = "no_if_activity.alert_no_activity_title",
|
||||
icon = "fas fa-arrow-circle-up",
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Prepare an alert table used to generate the alert
|
||||
-- @param one_param The first alert param
|
||||
-- @param another_param The second alert param
|
||||
-- @return A table with the alert built
|
||||
function alert_no_if_activity:init(one_param, another_param)
|
||||
-- Call the paren constructor
|
||||
self.super:init()
|
||||
|
||||
self.alert_type_params = {
|
||||
one_param = one_param,
|
||||
another_param = another_param
|
||||
}
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return {
|
||||
alert_key = alert_keys.ntopng.alert_no_if_activity,
|
||||
i18n_title = "no_if_activity.alert_no_activity_title",
|
||||
i18n_description = noIfActivity,
|
||||
icon = "fas fa-arrow-circle-up",
|
||||
creator = createNoIfActivity,
|
||||
}
|
||||
-- @brief Format an alert into a human-readable string
|
||||
-- @param ifid The integer interface id of the generated alert
|
||||
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
|
||||
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
|
||||
-- @return A human-readable string
|
||||
function alert_no_if_activity.format(ifid, alert, alert_type_params)
|
||||
i18n("no_if_activity.status_no_activity_description")
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return alert_no_if_activity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue