This is an automated email from the ASF dual-hosted git repository.
wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1eadf08258 AMBARI-25777: Service Issues in Host Checks incompatible
with Centos7 when hosts registered (#3484)
1eadf08258 is described below
commit 1eadf08258ac65ee925e5aa20680ac3a2bc2b5b5
Author: Yu Hou <[email protected]>
AuthorDate: Tue Nov 15 00:31:28 2022 +0800
AMBARI-25777: Service Issues in Host Checks incompatible with Centos7 when
hosts registered (#3484)
---
ambari-agent/src/main/python/ambari_agent/HostInfo.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 650eca190b..7bb4ac1b58 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -42,6 +42,7 @@ logger = logging.getLogger()
# service cmd
SERVICE_CMD = "service"
+REDHAT7_SERVICE_CMD = "systemctl"
class HostInfo(object):
@@ -192,6 +193,8 @@ class HostInfoLinux(HostInfo):
DEFAULT_SERVICE_NAME = "ntpd"
SERVICE_STATUS_CMD = "%s %s status" % (SERVICE_CMD, DEFAULT_SERVICE_NAME)
SERVICE_STATUS_CMD_LIST = shlex.split(SERVICE_STATUS_CMD)
+ REDHAT7_SERVICE_STATUS_CMD = "%s status %s" % (REDHAT7_SERVICE_CMD,
DEFAULT_SERVICE_NAME)
+ REDHAT7_SERVICE_STATUS_CMD_LIST = shlex.split(REDHAT7_SERVICE_STATUS_CMD)
THP_FILE_REDHAT = "/sys/kernel/mm/redhat_transparent_hugepage/enabled"
THP_FILE_UBUNTU = "/sys/kernel/mm/transparent_hugepage/enabled"
@@ -368,8 +371,12 @@ class HostInfoLinux(HostInfo):
pass
def getServiceStatus(self, service_name):
- service_check_live = list(self.SERVICE_STATUS_CMD_LIST)
- service_check_live[1] = service_name
+ if OSCheck.is_redhat_family() and int(OSCheck.get_os_major_version()) >= 7:
+ service_check_live = list(self.REDHAT7_SERVICE_STATUS_CMD_LIST)
+ service_check_live[2] = service_name
+ else:
+ service_check_live = list(self.SERVICE_STATUS_CMD_LIST)
+ service_check_live[1] = service_name
try:
code, out, err = shell.call(service_check_live, stdout =
subprocess32.PIPE, stderr = subprocess32.PIPE, timeout = 5, quiet = True)
return out, err, code
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]