You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/12/09 13:35:26 UTC

ambari git commit: AMBARI-14275. NodeManager Health Summary UNKNOWN from Standby ResourceManager.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/trunk c7c7bcad1 -> 1e6d80f3c


AMBARI-14275. NodeManager Health Summary UNKNOWN from Standby ResourceManager.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1e6d80f3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1e6d80f3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1e6d80f3

Branch: refs/heads/trunk
Commit: 1e6d80f3cdc66420af8047780efdc6318990f3f8
Parents: c7c7bca
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Wed Dec 9 14:34:21 2015 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Wed Dec 9 14:34:21 2015 +0200

----------------------------------------------------------------------
 .../python/ambari_agent/alerts/metric_alert.py  |  7 ++++++-
 .../libraries/functions/curl_krb_request.py     |  4 ++--
 .../alerts/alert_nodemanagers_summary.py        | 22 +++++++++++++++++---
 3 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1e6d80f3/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py b/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
index 8de49cd..b2f4e33 100644
--- a/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
+++ b/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
@@ -241,7 +241,12 @@ class MetricAlert(BaseAlert):
       if json_is_valid:
         for attr in jmx_property_value:
           if attr not in json_data:
-            raise Exception("Unable to find {0} in JSON from {1} ".format(attr, url))
+            beans = json_response['beans']
+            for jmx_prop_list_item in beans:
+              if "name" in jmx_prop_list_item and jmx_prop_list_item["name"] == jmx_property_key:
+                if attr not in jmx_prop_list_item:
+                  raise Exception("Unable to find {0} in JSON from {1} ".format(attr, url))
+                json_data = jmx_prop_list_item
 
           value_list.append(json_data[attr])
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1e6d80f3/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py b/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
index f5996fa..dc1d88f 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
@@ -99,12 +99,12 @@ def curl_krb_request(tmp_dir, keytab, principal, url, cache_file_prefix,
 
   try:
     if return_only_http_code:
-      _, curl_stdout, curl_stderr = get_user_call_output(['curl', '-k', '--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file, '-w',
+      _, curl_stdout, curl_stderr = get_user_call_output(['curl', '-L', '-k', '--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file, '-w',
                              '%{http_code}', url, '--connect-timeout', str(connection_timeout), '--max-time', str(maximum_timeout), '-o', '/dev/null'],
                              user=user, env=kerberos_env)
     else:
       # returns response body
-      _, curl_stdout, curl_stderr = get_user_call_output(['curl', '-k', '--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file,
+      _, curl_stdout, curl_stderr = get_user_call_output(['curl', '-L', '-k', '--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file,
                              url, '--connect-timeout', str(connection_timeout), '--max-time', str(maximum_timeout)],
                              user=user, env=kerberos_env)
   except Fail:

http://git-wip-us.apache.org/repos/asf/ambari/blob/1e6d80f3/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/alerts/alert_nodemanagers_summary.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/alerts/alert_nodemanagers_summary.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/alerts/alert_nodemanagers_summary.py
index b9a7094..119a1a1 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/alerts/alert_nodemanagers_summary.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/alerts/alert_nodemanagers_summary.py
@@ -46,6 +46,8 @@ CONNECTION_TIMEOUT_DEFAULT = 5.0
 LOGGER_EXCEPTION_MESSAGE = "[Alert] NodeManager Health Summary on {0} fails:"
 logger = logging.getLogger('ambari_alerts')
 
+QRY = "Hadoop:service=ResourceManager,name=RMNMInfo"
+
 def get_tokens():
   """
   Returns a tuple of tokens in the format {{site/property}} that will be used
@@ -116,7 +118,7 @@ def execute(configurations={}, parameters={}, host_name=None):
       uri = https_uri
 
   uri = str(host_name) + ":" + uri.split(":")[1]
-  live_nodemanagers_qry = "{0}://{1}/jmx?qry=Hadoop:service=ResourceManager,name=RMNMInfo".format(scheme, uri)
+  live_nodemanagers_qry = "{0}://{1}/jmx?qry={2}".format(scheme, uri, QRY)
   convert_to_json_failed = False
   response_code = None
   try:
@@ -132,7 +134,7 @@ def execute(configurations={}, parameters={}, host_name=None):
 
       try:
         url_response_json = json.loads(url_response)
-        live_nodemanagers = json.loads(url_response_json["beans"][0]["LiveNodeManagers"])
+        live_nodemanagers = json.loads(find_value_in_jmx(url_response_json, "LiveNodeManagers", live_nodemanagers_qry))
       except ValueError, error:
         convert_to_json_failed = True
         logger.exception("[Alert][{0}] Convert response to json failed or json doesn't contain needed data: {1}".
@@ -188,10 +190,24 @@ def get_value_from_jmx(query, jmx_property, connection_timeout):
 
     data = response.read()
     data_dict = json.loads(data)
-    return data_dict["beans"][0][jmx_property]
+    return find_value_in_jmx(data_dict, jmx_property, query)
   finally:
     if response is not None:
       try:
         response.close()
       except:
         pass
+
+
+def find_value_in_jmx(data_dict, jmx_property, query):
+  json_data = data_dict["beans"][0]
+
+  if jmx_property not in json_data:
+    beans = data_dict['beans']
+    for jmx_prop_list_item in beans:
+      if "name" in jmx_prop_list_item and jmx_prop_list_item["name"] == QRY:
+        if jmx_property not in jmx_prop_list_item:
+          raise Exception("Unable to find {0} in JSON from {1} ".format(jmx_property, query))
+        json_data = jmx_prop_list_item
+
+  return json_data[jmx_property]
\ No newline at end of file