mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Revert "Migrates alerts to an object-oriented implementation"
This reverts commit fbc283f12f.
This commit is contained in:
parent
fbc283f12f
commit
e24ef4ef35
108 changed files with 1741 additions and 2797 deletions
|
|
@ -2,63 +2,53 @@
|
|||
-- (C) 2019-20 - ntop.org
|
||||
--
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
local alert_keys = require "alert_keys"
|
||||
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
local format_utils = require "format_utils"
|
||||
|
||||
-- Import the classes library.
|
||||
local classes = require "classes"
|
||||
-- Make sure to import the Superclass!
|
||||
local alert = require "alert"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local alert_slow_periodic_activity = classes.class(alert)
|
||||
|
||||
-- ##############################################
|
||||
|
||||
alert_slow_periodic_activity.meta = {
|
||||
alert_key = alert_keys.ntopng.alert_slow_periodic_activity,
|
||||
i18n_title = "alerts_dashboard.slow_periodic_activity",
|
||||
icon = "fas fa-undo",
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
-- #######################################################
|
||||
|
||||
-- @brief Prepare an alert table used to generate the alert
|
||||
-- @param alert_severity A severity as defined in `alert_severities`
|
||||
-- @param alert_granularity A granularity as defined in `alert_consts.alerts_granularities`
|
||||
-- @param ps_name A string with the name of the periodic activity
|
||||
-- @param max_duration_ms The maximum duration taken by this periodic activity to run, in milliseconds
|
||||
-- @return A table with the alert built
|
||||
function alert_slow_periodic_activity:init(ps_name, max_duration_ms)
|
||||
-- Call the paren constructor
|
||||
self.super:init()
|
||||
|
||||
self.alert_type_params = {
|
||||
ps_name = ps_name,
|
||||
max_duration_ms = max_duration_ms,
|
||||
local function createSlowPeriodicActivity(alert_severity, alert_granularity, ps_name, max_duration_ms)
|
||||
local threshold_type = {
|
||||
alert_severity = alert_severity,
|
||||
alert_granularity = alert_granularity,
|
||||
alert_subtype = ps_name,
|
||||
alert_type_params = {
|
||||
ps_name = ps_name,
|
||||
max_duration_ms = max_duration_ms,
|
||||
},
|
||||
}
|
||||
|
||||
return threshold_type
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
-- @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_slow_periodic_activity.format(ifid, alert, alert_type_params)
|
||||
local function slowPeriodicActivityFormatter(ifid, alert, info)
|
||||
local max_duration
|
||||
|
||||
max_duration = format_utils.secondsToTime(alert_type_params.max_duration_ms / 1000)
|
||||
max_duration = format_utils.secondsToTime(info.max_duration_ms / 1000)
|
||||
|
||||
return(i18n("alert_messages.slow_periodic_activity", {
|
||||
script = alert_type_params.ps_name,
|
||||
script = info.ps_name,
|
||||
max_duration = max_duration,
|
||||
}))
|
||||
end
|
||||
|
||||
return alert_slow_periodic_activity
|
||||
-- #######################################################
|
||||
|
||||
return {
|
||||
alert_key = alert_keys.ntopng.alert_slow_periodic_activity,
|
||||
i18n_title = "alerts_dashboard.slow_periodic_activity",
|
||||
i18n_description = slowPeriodicActivityFormatter,
|
||||
icon = "fas fa-undo",
|
||||
creator = createSlowPeriodicActivity,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue