You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mi...@apache.org on 2016/04/15 21:27:42 UTC
ambari git commit: AMBARI-15794: HAWQ Segment Registration Status
Alert shows false alert (Lav Jain via mithmatt)
Repository: ambari
Updated Branches:
refs/heads/trunk e5c13a3ad -> 0f9d0b087
AMBARI-15794: HAWQ Segment Registration Status Alert shows false alert (Lav Jain via mithmatt)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0f9d0b08
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0f9d0b08
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0f9d0b08
Branch: refs/heads/trunk
Commit: 0f9d0b0870e240ca2da47d9d28bc9c298f8edf4b
Parents: e5c13a3
Author: Matt <mm...@pivotal.io>
Authored: Fri Apr 15 12:26:06 2016 -0700
Committer: Matt <mm...@pivotal.io>
Committed: Fri Apr 15 12:26:06 2016 -0700
----------------------------------------------------------------------
.../alerts/alert_segment_registration_status.py | 23 +++++++++++---------
1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0f9d0b08/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py
index 4d09763..17724bc 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py
@@ -58,22 +58,28 @@ def execute(configurations={}, parameters={}, host_name=None):
logger.error("[Alert HAWQ] Configurations file is either not accessible or not present.")
return (RESULT_STATE_UNKNOWN, ['There were no configurations supplied to the script.'])
logger.debug("Configuration File found")
+
if not os.path.isfile(HAWQ_SLAVES_FILE):
logger.error("[Alert HAWQ] Slaves file is not present in {0}".format(HAWQ_SLAVES_FILE))
return (RESULT_STATE_SKIPPED, ['Slaves file is not present in /usr/local/hawq/etc'])
try:
- db_segment_list = get_segment_list_db(configurations[HAWQMASTER_PORT])
ambari_segment_list = get_segment_list_ambari()
+ db_segment_list = get_segment_list_db(configurations[HAWQMASTER_PORT])
+ # Replace any occurence of 'localhost' in segment_list with host_name
+ hawq_segment_list = [host_name if name == 'localhost' else name for name in db_segment_list]
+
#Converted to set to omit any duplicates inserted into slaves file
- segment_diff = (set(db_segment_list) ^ set(ambari_segment_list))
+ segment_diff = (set(hawq_segment_list) ^ set(ambari_segment_list))
segment_diff_len = len(segment_diff)
#segment_diff_len cannot be negative since this diff is calculated two ways. (eg: "A - B" & "B - A")
if not segment_diff_len :
return (RESULT_STATE_OK, ['All HAWQ Segments are registered.'])
- msg = '{0} HAWQ Segments are not registered with HAWQ Master.'.format(segment_diff_len) if (segment_diff_len > 1) else '1 HAWQ Segment is not registered with HAWQ Master.'
+
+ msg = '{0} HAWQ Segments are not registered with HAWQ Master.'.format(segment_diff_len) if (segment_diff_len > 1) else '1 HAWQ Segment is not registered with HAWQ Master.'
logger.error(" [Alert HAWQ] Segments Unregistered: {0} are unregistered/down.".format(list(segment_diff)))
return (RESULT_STATE_WARNING, [msg + " Try restarting HAWQ service if a segment has been added/removed. Check the log file in /var/log/ambari-agent/ambari-alerts.log for more details on unregistered hosts."])
+
except Exception, ex:
logger.error('[Alert HAWQ] Could not find HAWQ Segments registration status on {0}'.format(host_name))
logger.exception(str(ex))
@@ -90,14 +96,12 @@ def get_segment_list_db(port):
query = " SELECT hostname FROM gp_segment_configuration where role = 'p' and status = 'u' "
cmd = "source {0} && psql -p {1} -t -d template1 -c \"{2};\"".format(HAWQ_GREENPLUM_PATH_FILE, port, query)
- returncode, command_output = call(cmd,
- user=HAWQ_USER,
- timeout=60)
-
+ returncode, command_output = call(cmd, user=HAWQ_USER, timeout=60)
if returncode:
raise
- segment_list = [segment.strip() for segment in command_output.split('\n')] if command_output else []
- return [hostname.strip() for hostname in segment_list]
+
+ return [segment.strip() for segment in command_output.split('\n')] if command_output else []
+
def get_segment_list_ambari():
"""
@@ -114,4 +118,3 @@ def get_segment_list_ambari():
except Exception as ex:
logger.error("[Alert HAWQ] Get Segment list from Slaves : Could not read slaves from {0}".format(HAWQ_SLAVES_FILE))
raise ex
-