mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Fixed #2959 handle new -X/-x settings when the respective messages appear
This commit is contained in:
parent
ec1a00f879
commit
20a8bb115a
6 changed files with 132 additions and 21 deletions
60
scripts/lua/modules/configuration_utils.lua
Normal file
60
scripts/lua/modules/configuration_utils.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
--
|
||||
-- (C) 2013-20 - ntop.org
|
||||
--
|
||||
|
||||
require "lua_utils"
|
||||
local sys_utils = require "sys_utils"
|
||||
local rest_utils = require("rest_utils")
|
||||
|
||||
local conf_utils = {}
|
||||
|
||||
local redis_key = "increased_max_num_host_or_flows"
|
||||
local dir = "/bin/ntopng/ntopng-config"
|
||||
|
||||
-- ################################################################
|
||||
|
||||
function conf_utils.increase_num_host_num_flows(incr_num_hosts, incr_num_flows)
|
||||
local exit_status = ""
|
||||
|
||||
-- Double the value of the hosts or of the flows
|
||||
if incr_num_hosts then
|
||||
exit_status = sys_utils.execShellCmd(dir .. " -x *2")
|
||||
elseif incr_num_flows then
|
||||
exit_status = sys_utils.execShellCmd(dir .. " -X *2")
|
||||
end
|
||||
|
||||
local res = {
|
||||
exit_status = exit_status
|
||||
}
|
||||
|
||||
if string.match(exit_status, "succesfully changed") then
|
||||
-- Set the redis key for the restart
|
||||
ntop.setCache(redis_key, true)
|
||||
rest_utils.answer(rest_utils.consts.success.ok, res)
|
||||
return
|
||||
end
|
||||
|
||||
rest_utils.answer(rest_utils.consts.err.internal_error, res)
|
||||
end
|
||||
|
||||
-- #################################
|
||||
|
||||
function conf_utils.restart_required()
|
||||
if ntop.getCache(redis_key) == '' then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- #################################
|
||||
|
||||
function conf_utils.reset()
|
||||
if ntop.getCache(redis_key) ~= '' then
|
||||
ntop.delCache(redis_key)
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################
|
||||
|
||||
return conf_utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue