Updated Branches:
  refs/heads/trunk 4be888c57 -> 57281c722

AMBARI-2850. ntpd service shows up with error in the agent env. (swagle)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/57281c72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/57281c72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/57281c72

Branch: refs/heads/trunk
Commit: 57281c7224686c77717de9bfebc3d7b387caed67
Parents: 4be888c
Author: Siddharth Wagle <[email protected]>
Authored: Fri Aug 9 14:56:10 2013 -0700
Committer: Siddharth Wagle <[email protected]>
Committed: Fri Aug 9 14:56:10 2013 -0700

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/HostInfo.py        | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/57281c72/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py 
b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 5ade94e..48aa659 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -43,9 +43,9 @@ class HostInfo:
     "sqoop-ambari-qa", "sqoop-ambari_qa"
   ]
 
-  # List of live services checked for on the host
+  # List of live services checked for on the host, takes a map of plan strings
   DEFAULT_LIVE_SERVICES = [
-    "ntpd"
+    {"redhat":"ntpd", "suse":"ntp"}
   ]
 
   # Set of default users (need to be replaced with the configured user names)
@@ -144,14 +144,24 @@ class HostInfo:
         result['target'] = realConf
         etcResults.append(result)
 
+  def get_os_type(self):
+    os_info = platform.linux_distribution(None, None, None, ['SuSE',
+                                          'redhat' ], 0)
+    return os_info[0].lower()
+
   def checkLiveServices(self, services, result):
+    osType = self.get_os_type()
     for service in services:
       svcCheckResult = {}
       svcCheckResult['name'] = service
       svcCheckResult['status'] = "UNKNOWN"
       svcCheckResult['desc'] = ""
+      if isinstance(service, dict):
+        serviceName = service[osType]
+      else:
+        serviceName = service
       try:
-        cmd = "service " + service + " status"
+        cmd = "/sbin/service " + serviceName + " status"
         osStat = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
         out, err = osStat.communicate()

Reply via email to