mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Pools configuration in Recipients (WIP)
This commit is contained in:
parent
6c9dd9f7df
commit
dcd23241c7
17 changed files with 263 additions and 43 deletions
|
|
@ -6,6 +6,8 @@ local dirs = ntop.getDirs()
|
|||
require "lua_utils"
|
||||
local alert_severities = require "alert_severities"
|
||||
local checks = require "checks"
|
||||
local host_pools = require "host_pools":create()
|
||||
local interface_pools = require "interface_pools":create()
|
||||
|
||||
-- ##############################################
|
||||
|
||||
|
|
@ -40,6 +42,62 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Parses and validates a comma-separated list of host pool ids into a lua array
|
||||
-- @return A lua array of valid ids
|
||||
function recipients_rest_utils.parse_host_pools(pools_string)
|
||||
local pools = host_pools:get_all_pools()
|
||||
local pools_list = {}
|
||||
|
||||
if isEmptyString(pools_string) then return pools_list end
|
||||
|
||||
-- Unfold the pools csv
|
||||
pools_list = pools_string:split(",") or {pools_string}
|
||||
|
||||
local res = {}
|
||||
for _, pool_id in pairs(pools_list) do
|
||||
local pool_id = tonumber(pool_id)
|
||||
|
||||
for _, pool in pairs(pools) do
|
||||
if pool_id == pool.pool_id then
|
||||
res[#res + 1] = pool_id
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Parses and validates a comma-separated list of interface pool ids into a lua array
|
||||
-- @return A lua array of valid ids
|
||||
function recipients_rest_utils.parse_interface_pools(pools_string)
|
||||
local pools = interface_pools:get_all_pools()
|
||||
local pools_list = {}
|
||||
|
||||
if isEmptyString(pools_string) then return pools_list end
|
||||
|
||||
-- Unfold the pools csv
|
||||
pools_list = pools_string:split(",") or {pools_string}
|
||||
|
||||
local res = {}
|
||||
for _, pool_id in pairs(pools_list) do
|
||||
local pool_id = tonumber(pool_id)
|
||||
|
||||
for _, pool in pairs(pools) do
|
||||
if pool_id == pool.pool_id then
|
||||
res[#res + 1] = pool_id
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Parses and validates a severity id string and returns it as a number
|
||||
-- @param minimum_severity_id_string An string with an integer severity id as found in `alert_severities`
|
||||
-- @return A valid integer severity id or nil when validation fails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue