ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mithm...@apache.org
Subject ambari git commit: AMBARI-15794: HAWQ Segment Registration Status Alert shows false alert (Lav Jain via mithmatt)
Date Fri, 15 Apr 2016 19:32:35 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2.2 ff7245d8c -> d54c917f7


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/d54c917f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d54c917f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d54c917f

Branch: refs/heads/branch-2.2.2
Commit: d54c917f720c5f6b0109dfe46cdab7e924622591
Parents: ff7245d
Author: Matt <mmathew@pivotal.io>
Authored: Fri Apr 15 12:31:45 2016 -0700
Committer: Matt <mmathew@pivotal.io>
Committed: Fri Apr 15 12:31:45 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/d54c917f/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 1f327a4..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
-  
\ No newline at end of file


Mime
View raw message