Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 e0006f868 -> ab366e2fe


AMBARI-14697 : AMS monitor should use same hostname as ambari agent and server. 
(avijayan)


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

Branch: refs/heads/branch-2.2
Commit: ab366e2fea6874cd481e07ffa96c33fb4f6f95dd
Parents: e0006f8
Author: Aravindan Vijayan <avija...@hortonworks.com>
Authored: Fri Jan 15 15:22:25 2016 -0800
Committer: Aravindan Vijayan <avija...@hortonworks.com>
Committed: Fri Jan 15 15:22:25 2016 -0800

----------------------------------------------------------------------
 .../conf/unix/metric_monitor.ini                        |  1 +
 .../src/main/python/core/config_reader.py               |  3 +++
 .../src/main/python/core/host_info.py                   | 12 ++----------
 .../0.1.0/package/templates/metric_monitor.ini.j2       |  1 +
 4 files changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ab366e2f/ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini
----------------------------------------------------------------------
diff --git 
a/ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini 
b/ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini
index 2403a14..d302518 100644
--- a/ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini
+++ b/ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini
@@ -19,6 +19,7 @@
 [default]
 debug_level = INFO
 metrics_server = localhost:{{ams_collector_port}}
+hostname = {{hostname}}
 enable_time_threshold = false
 enable_value_threshold = false
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ab366e2f/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
----------------------------------------------------------------------
diff --git 
a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
 
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
index a3780ff..48f5af2 100644
--- 
a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
+++ 
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
@@ -195,6 +195,9 @@ class Configuration:
   def get_server_address(self):
     return self.get("default", "metrics_server")
 
+  def get_hostname_config(self):
+    return self.get("default", "hostname", None)
+
   def get_hostname_script(self):
     if self.hostname_script:
       return self.hostname_script

http://git-wip-us.apache.org/repos/asf/ambari/blob/ab366e2f/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
----------------------------------------------------------------------
diff --git 
a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
 
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
index 60e9294..23fc4de 100644
--- 
a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
+++ 
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
@@ -287,16 +287,8 @@ class HostInfo():
       return cached_hostname
 
     try:
-      hostname_script = self.__config.get_hostname_script()
-      logger.info('hostname_script: %s' % hostname_script)
-      try:
-        osStat = subprocess.Popen([hostname_script], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
-        out, err = osStat.communicate()
-        if (0 == osStat.returncode and 0 != len(out.strip())):
-          cached_hostname = out.strip()
-        else:
-          cached_hostname = socket.getfqdn().lower()
-      except:
+      cached_hostname = self.__config.get_hostname_config()
+      if not cached_hostname:
         cached_hostname = socket.getfqdn().lower()
     except:
       cached_hostname = socket.getfqdn().lower()

http://git-wip-us.apache.org/repos/asf/ambari/blob/ab366e2f/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2
 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2
index fef60b7..fc86a58 100644
--- 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2
+++ 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2
@@ -19,6 +19,7 @@
 [default]
 debug_level = INFO
 metrics_server = {{metric_collector_host}}:{{metric_collector_port}}
+hostname = {{hostname}}
 enable_time_threshold = false
 enable_value_threshold = false
 

Reply via email to