Fixes some lua requires

This commit is contained in:
Matteo Biscosi 2024-02-20 08:57:45 +00:00
parent 14d9dd5bb4
commit e243f7c826
7 changed files with 25 additions and 11 deletions

View file

@ -12,7 +12,6 @@ local format_utils = require "format_utils"
local alert_consts = require "alert_consts"
local alert_utils = require "alert_utils"
local alert_severities = require "alert_severities"
local alert_roles = require "alert_roles"
local tag_utils = require "tag_utils"
local alert_entities = require "alert_entities"
local checks = require "checks"

View file

@ -10,12 +10,10 @@ local classes = require "classes"
require "lua_utils"
local alert_store = require "alert_store"
local format_utils = require "format_utils"
local alert_consts = require "alert_consts"
local alert_utils = require "alert_utils"
local alert_entities = require "alert_entities"
local tag_utils = require "tag_utils"
local json = require "dkjson"
-- ##############################################

View file

@ -659,7 +659,7 @@ function format_utils.formatMessage(notification, options)
-- In case it is an alert, format it by using the standard function
local alert_utils = require "alert_utils"
local message = alert_utils.formatAlertNotification(notification, options)
local message = alert_utils.formatAlertNotification(notification, options)
return message
end

View file

@ -18,6 +18,27 @@ local clock_start = os.clock()
-- ##############################################
-- split
function split(s, delimiter)
result = {};
if(s ~= nil) then
if delimiter == nil then
-- No delimiter, split all characters
for match in s:gmatch"." do
table.insert(result, match);
end
else
-- Split by delimiter
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
end
end
return result;
end
-- ##############################################
function ends(String, End)
return End == '' or string.sub(String, -string.len(End)) == End
end
@ -666,6 +687,7 @@ end
-- @param skip_first if true, 0 will be returned when no cached value is present
-- @return the difference between current and previous value
function delta_val(reg, metric_name, granularity, curr_val, skip_first)
-- This require is okay, alert_granularities is just a struct
local alert_granularities = require "alert_granularities"
local granularity_num = alert_granularities[granularity] or 0

View file

@ -7,7 +7,6 @@ local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/notifications/?.lua;" .. package.path
local os_utils = require("os_utils")
local file_utils = require("file_utils")
local template_utils = require("template_utils")
local lua_path_utils = require("lua_path_utils")
require "lua_trace"

View file

@ -4,8 +4,6 @@
local clock_start = os.clock()
local json = require "dkjson"
local tracker = {}
@ -13,8 +11,7 @@ local tracker = {}
--! @param f_name is the function name
--! @param f_args is a table with the arguments
function tracker.log(f_name, f_args)
local alert_utils = require("alert_utils")
local alerts_api = require("alerts_api")
local alert_entity_builders = require("alert_entity_builders")
local alert_consts = require "alert_consts"
local stats = interface.getStats()
@ -50,7 +47,7 @@ function tracker.log(f_name, f_args)
alert:set_score_notice()
alert:set_subtype('function'.."/"..(f_name or '').."/"..(remote_addr or ''))
alert:store(alerts_api.userEntity(entity_value))
alert:store(alert_entity_builders.userEntity(entity_value))
interface.select(tostring(old_iface))
end