mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Implements auto assignment of user script alert and status ids
This commit is contained in:
parent
d7528e1628
commit
48910b9f87
58 changed files with 55 additions and 68 deletions
|
|
@ -3,6 +3,7 @@
|
|||
--
|
||||
|
||||
local plugins_utils = {}
|
||||
local plugins_consts_utils = require("plugins_consts_utils")
|
||||
|
||||
local os_utils = require("os_utils")
|
||||
local persistence = require("persistence")
|
||||
|
|
@ -158,6 +159,31 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
local function init_plugin_consts_ids(defs_dir, const_type)
|
||||
for fname in pairs(ntop.readdir(defs_dir) or {}) do
|
||||
if string.ends(fname, ".lua") then
|
||||
local mod_fname = string.sub(fname, 1, string.len(fname) - 4)
|
||||
plugins_consts_utils.request_id(const_type, mod_fname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function init_plugins(plugins)
|
||||
for _, plugin in ipairs(plugins) do
|
||||
init_plugin_consts_ids(os_utils.fixPath(plugin.path .. "/alert_definitions"), "alert")
|
||||
end
|
||||
plugins_consts_utils.assign_requested_ids("alert")
|
||||
|
||||
for _, plugin in ipairs(plugins) do
|
||||
init_plugin_consts_ids(os_utils.fixPath(plugin.path .. "/status_definitions"), "flow")
|
||||
end
|
||||
plugins_consts_utils.assign_requested_ids("flow")
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- NOTE: cannot save the definitions to a single file via the persistance
|
||||
-- module because they may contain functions (e.g. in the i18n_description)
|
||||
local function load_definitions(defs_dir, runtime_path, validator)
|
||||
|
|
@ -184,6 +210,8 @@ local function load_definitions(defs_dir, runtime_path, validator)
|
|||
return(true)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function load_plugin_definitions(plugin, alert_definitions, status_definitions)
|
||||
local alert_consts = require("alert_consts")
|
||||
local flow_consts = require("flow_consts")
|
||||
|
|
@ -435,6 +463,8 @@ function plugins_utils.loadPlugins()
|
|||
alert_consts.resetDefinitions()
|
||||
flow_consts.resetDefinitions()
|
||||
|
||||
init_plugins(plugins)
|
||||
|
||||
-- Load the plugins following the dependecies order
|
||||
for _, plugin in ipairs(plugins) do
|
||||
-- Ensure that the depencies has been loaded as well
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue