summaryrefslogtreecommitdiff
path: root/ambari-metrics/ambari-metrics-host-monitoring
diff options
context:
space:
mode:
authorSiddharth Wagle <swagle@hortonworks.com>2015-01-22 18:35:54 -0800
committerSiddharth Wagle <swagle@hortonworks.com>2015-01-22 18:35:54 -0800
commitc99ebb5cf0bed3f1bc1a44efa86628f4ec423b3f (patch)
tree3b2681598f51cfcd403c3580bf7cbe77f783dead /ambari-metrics/ambari-metrics-host-monitoring
parentc579d2747e01543bb5dd9bf6ed4e16a87fc7c4c7 (diff)
AMBARI-9278. Allow hostname customization for metric monitor. Use agent conf. (swagle)
Diffstat (limited to 'ambari-metrics/ambari-metrics-host-monitoring')
-rw-r--r--ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py20
-rw-r--r--ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py1
2 files changed, 18 insertions, 3 deletions
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 f43f512275..a3780ffac5 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")
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 37c55cbed6..caa972c931 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