Repository: ambari Updated Branches: refs/heads/trunk c579d2747 -> c99ebb5cf
AMBARI-9278. Allow hostname customization for metric monitor. Use agent conf. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c99ebb5c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c99ebb5c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c99ebb5c Branch: refs/heads/trunk Commit: c99ebb5cf0bed3f1bc1a44efa86628f4ec423b3f Parents: c579d27 Author: Siddharth Wagle <swa...@hortonworks.com> Authored: Thu Jan 22 18:35:54 2015 -0800 Committer: Siddharth Wagle <swa...@hortonworks.com> Committed: Thu Jan 22 18:35:54 2015 -0800 ---------------------------------------------------------------------- .../src/main/python/core/config_reader.py | 20 ++++++++++++++++++-- .../src/main/python/core/host_info.py | 1 - 2 files changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c99ebb5c/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 f43f512..a3780ff 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 @@ -61,7 +61,6 @@ class ConfigDefaultsLinux(ConfigDefaults): configDefaults = ConfigDefaults() - config = ConfigParser.RawConfigParser() CONFIG_FILE_PATH = configDefaults.get_config_file_path() @@ -84,6 +83,8 @@ STOP_ACTION = "stop" RESTART_ACTION = "restart" STATUS_ACTION = "status" +AMBARI_AGENT_CONF = '/etc/ambari-agent/conf/ambari-agent.ini' + config_content = """ [default] debug_level = INFO @@ -139,6 +140,7 @@ metric_group_info = """ } """ + class Configuration: def __init__(self): @@ -160,6 +162,17 @@ class Configuration: } pass + self.hostname_script = None + ambari_agent_config = ConfigParser.RawConfigParser() + if os.path.exists(AMBARI_AGENT_CONF): + try: + ambari_agent_config.read(AMBARI_AGENT_CONF) + self.hostname_script = ambari_agent_config.get('agent', 'hostname_script') + except: + # No hostname script identified in the ambari agent conf + pass + pass + def getConfig(self): return self.config @@ -183,7 +196,10 @@ class Configuration: return self.get("default", "metrics_server") def get_hostname_script(self): - return self.get("default", "hostname_script") + if self.hostname_script: + return self.hostname_script + else: + return self.get("default", "hostname_script") def get_log_level(self): return self.get("default", "debug_level", "INFO") http://git-wip-us.apache.org/repos/asf/ambari/blob/c99ebb5c/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 37c55cb..caa972c 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 @@ -23,7 +23,6 @@ import psutil import os from collections import namedtuple import platform -import socket import time import threading import socket