mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Reduce pam auth message logs
This commit is contained in:
parent
a650f3f27e
commit
ed05294aa8
1 changed files with 15 additions and 10 deletions
|
|
@ -7,7 +7,7 @@ local dirs = ntop.getDirs()
|
|||
local tracker = require "tracker"
|
||||
|
||||
local os_utils = {}
|
||||
local NTOPCTL_CMD = "sudo ntopctl"
|
||||
local NTOPCTL_CMD = "ntopctl"
|
||||
local NTOPNG_CONFIG_TOOL = "/usr/bin/ntopng-utils-manage-config"
|
||||
local is_windows = ntop.isWindows()
|
||||
|
||||
|
|
@ -61,15 +61,20 @@ end
|
|||
|
||||
-- ########################################################
|
||||
|
||||
local function ntopctl_cmd(service_name, ...)
|
||||
local function ntopctl_cmd(service_name, use_sudo, ...)
|
||||
local cmd = {NTOPCTL_CMD, service_name, ...}
|
||||
|
||||
if use_sudo then
|
||||
table.insert(cmd, 1, "sudo")
|
||||
end
|
||||
|
||||
return table.concat(cmd, " ")
|
||||
end
|
||||
|
||||
--! @brief Execute service control tool and get its output.
|
||||
--! @return Command output. See os_utils.execWithOutput for details.
|
||||
function os_utils.ntopctlCmd(service_name, ...)
|
||||
return os_utils.execWithOutput(ntopctl_cmd(service_name, ...))
|
||||
return os_utils.execWithOutput(ntopctl_cmd(service_name, true, ...))
|
||||
end
|
||||
|
||||
-- ########################################################
|
||||
|
|
@ -93,7 +98,7 @@ function os_utils.hasService(service_name, ...)
|
|||
return false
|
||||
end
|
||||
|
||||
local cmd = ntopctl_cmd(service_name, "has-service", ...)
|
||||
local cmd = ntopctl_cmd(service_name, true, "has-service", ...)
|
||||
local rv = os_utils.execWithOutput(cmd)
|
||||
return(rv == "yes\n")
|
||||
end
|
||||
|
|
@ -103,7 +108,7 @@ end
|
|||
--! @brief Enable a service
|
||||
--! @return true if service was enabled successfully, false otherwise
|
||||
function os_utils.enableService(service_name, ...)
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, "enable", ...))
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, true, "enable", ...))
|
||||
return os_utils.isEnabled(service_name)
|
||||
end
|
||||
|
||||
|
|
@ -112,7 +117,7 @@ end
|
|||
--! @brief Disable a service
|
||||
--! @return true if service was disabled successfully, false otherwise
|
||||
function os_utils.disableService(service_name, ...)
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, "disable", ...))
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, true, "disable", ...))
|
||||
return not os_utils.isEnabled(service_name)
|
||||
end
|
||||
|
||||
|
|
@ -121,7 +126,7 @@ end
|
|||
--! @brief Restart a service
|
||||
--! @note See os_utils.execWithOutput for return value
|
||||
function os_utils.restartService(service_name, ...)
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, "restart", ...))
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, true, "restart", ...))
|
||||
return(os_utils.serviceStatus(service_name) == "active")
|
||||
end
|
||||
|
||||
|
|
@ -130,7 +135,7 @@ end
|
|||
--! @brief Stop a service
|
||||
--! @note See os_utils.execWithOutput for return value
|
||||
function os_utils.stopService(service_name, ...)
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, "stop", ...))
|
||||
os_utils.execWithOutput(ntopctl_cmd(service_name, true, "stop", ...))
|
||||
return(os_utils.serviceStatus(service_name) == "inactive")
|
||||
end
|
||||
|
||||
|
|
@ -139,7 +144,7 @@ end
|
|||
--! @brief Check the service status.
|
||||
--! @return active|inactive|error
|
||||
function os_utils.serviceStatus(service_name, ...)
|
||||
local rv = os_utils.execWithOutput(ntopctl_cmd(service_name, "is-active", ...))
|
||||
local rv = os_utils.execWithOutput(ntopctl_cmd(service_name, false, "is-active", ...))
|
||||
|
||||
if rv == "active\n" then
|
||||
return "active"
|
||||
|
|
@ -161,7 +166,7 @@ end
|
|||
-- ########################################################
|
||||
|
||||
function os_utils.isEnabled(service_name, ...)
|
||||
local rv = os_utils.execWithOutput(ntopctl_cmd(service_name, "is-enabled", ...))
|
||||
local rv = os_utils.execWithOutput(ntopctl_cmd(service_name, false, "is-enabled", ...))
|
||||
return(rv == "enabled")
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue