mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Changed nedge dhcp service management
This commit is contained in:
parent
bc5757be0c
commit
32b5ad3942
2 changed files with 55 additions and 2 deletions
51
scripts/lua/modules/dhcp_service_utils.lua
Normal file
51
scripts/lua/modules/dhcp_service_utils.lua
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
--
|
||||
-- (C) 2013-22 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
local sys_utils = require "sys_utils"
|
||||
local service_name = "isc-dhcp-server"
|
||||
|
||||
local redis_key = "ntopng.nedge.dhcp.enabled"
|
||||
|
||||
local dhcp_service_utils = {}
|
||||
|
||||
-- This function is used to check if the DHCP server status is up
|
||||
-- and if not, restart it.
|
||||
function dhcp_service_utils.checkRestartDHCPService()
|
||||
if ntop.isnEdge() then
|
||||
if (ntop.getCache(redis_key) or '0') == '1' then
|
||||
if not sys_utils.isActiveService(service_name) then
|
||||
sys_utils.restartService(service_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ###############################################################
|
||||
|
||||
-- This function is used to check if the DHCP server status is up
|
||||
-- and if not, restart it.
|
||||
function dhcp_service_utils.startDHCPservice()
|
||||
if ntop.isnEdge() then
|
||||
ntop.setCache(redis_key, '1')
|
||||
sys_utils.enableService(service_name)
|
||||
sys_utils.restartService(service_name)
|
||||
end
|
||||
end
|
||||
|
||||
-- ###############################################################
|
||||
|
||||
-- This function is used to check if the DHCP server status is up
|
||||
-- and if not, restart it.
|
||||
function dhcp_service_utils.stopDHCPservice()
|
||||
if ntop.isnEdge() then
|
||||
ntop.setCache(redis_key, '0')
|
||||
sys_utils.disableService(service_name)
|
||||
sys_utils.stopService(service_name)
|
||||
end
|
||||
end
|
||||
|
||||
return dhcp_service_utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue