Repository: ambari Updated Branches: refs/heads/branch-2.5 3099b2ed9 -> f353d013a
AMBARI-19746 Ambari HDFS Metric alerts turns to UNKNOWN status with error "argument of type 'NoneType' is not iterable" (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f353d013 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f353d013 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f353d013 Branch: refs/heads/branch-2.5 Commit: f353d013adad3680a7a60697baaf4d96f75a66bc Parents: 3099b2e Author: Dmytro Sen <d...@apache.org> Authored: Fri Jan 27 19:06:52 2017 +0200 Committer: Dmytro Sen <d...@apache.org> Committed: Fri Jan 27 19:08:27 2017 +0200 ---------------------------------------------------------------------- .../src/main/python/ambari_commons/ambari_metrics_helper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f353d013/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py index bfc786c..7841bde 100644 --- a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py +++ b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py @@ -24,6 +24,7 @@ from resource_management.libraries.functions import conf_select DEFAULT_COLLECTOR_SUFFIX = '.sink.timeline.collector.hosts' DEFAULT_METRICS2_PROPERTIES_FILE_NAME = 'hadoop-metrics2.properties' +DEFAULT_HADOOP_CONF_DIR_PATH = '/usr/hdp/current/hadoop-client/conf/' def select_metric_collector_for_sink(sink_name): # TODO check '*' sink_name @@ -42,7 +43,11 @@ def get_random_host(hosts): return random.choice(hosts) def get_metric_collectors_from_properties_file(sink_name): - hadoop_conf_dir = conf_select.get_hadoop_conf_dir() + try: + hadoop_conf_dir = conf_select.get_hadoop_conf_dir() + except Exception as e: + print "Can't get hadoop conf directory from conf_select.get_hadoop_conf_dir() - " + str(e) + hadoop_conf_dir = DEFAULT_HADOOP_CONF_DIR_PATH props = load_properties_from_file(os.path.join(hadoop_conf_dir, DEFAULT_METRICS2_PROPERTIES_FILE_NAME)) return props.get(sink_name + DEFAULT_COLLECTOR_SUFFIX) @@ -59,4 +64,4 @@ def load_properties_from_file(filepath, sep='=', comment_char='#'): key = key_value[0].strip() value = sep.join(key_value[1:]).strip('" \t') props[key] = value - return props \ No newline at end of file + return props