فهرست منبع

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

Aravindan Vijayan 9 سال پیش
والد
کامیت
9404e2439f

+ 1 - 0
ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_monitor.ini

@@ -19,6 +19,7 @@
 [default]
 [default]
 debug_level = INFO
 debug_level = INFO
 metrics_server = localhost:{{ams_collector_port}}
 metrics_server = localhost:{{ams_collector_port}}
+hostname = {{hostname}}
 enable_time_threshold = false
 enable_time_threshold = false
 enable_value_threshold = false
 enable_value_threshold = false
 
 

+ 3 - 0
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py

@@ -195,6 +195,9 @@ class Configuration:
   def get_server_address(self):
   def get_server_address(self):
     return self.get("default", "metrics_server")
     return self.get("default", "metrics_server")
 
 
+  def get_hostname_config(self):
+    return self.get("default", "hostname", None)
+
   def get_hostname_script(self):
   def get_hostname_script(self):
     if self.hostname_script:
     if self.hostname_script:
       return self.hostname_script
       return self.hostname_script

+ 2 - 10
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py

@@ -289,16 +289,8 @@ class HostInfo():
       return cached_hostname
       return cached_hostname
 
 
     try:
     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()
         cached_hostname = socket.getfqdn().lower()
     except:
     except:
       cached_hostname = socket.getfqdn().lower()
       cached_hostname = socket.getfqdn().lower()

+ 1 - 0
ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/metric_monitor.ini.j2

@@ -19,6 +19,7 @@
 [default]
 [default]
 debug_level = INFO
 debug_level = INFO
 metrics_server = {{metric_collector_host}}:{{metric_collector_port}}
 metrics_server = {{metric_collector_host}}:{{metric_collector_port}}
+hostname = {{hostname}}
 enable_time_threshold = false
 enable_time_threshold = false
 enable_value_threshold = false
 enable_value_threshold = false