Repository: ambari
Updated Branches:
  refs/heads/trunk 79cffa16d -> ec37c603c


http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_hive_thrift_port.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_hive_thrift_port.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_hive_thrift_port.py
deleted file mode 100644
index 36d04b3..0000000
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_hive_thrift_port.py
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import json
-import socket
-import time
-import traceback
-import urllib2
-from resource_management.libraries.functions import hive_check
-from resource_management.libraries.functions import format
-from resource_management.libraries.functions import get_kinit_path
-from resource_management.core.environment import Environment
-
-OK_MESSAGE = "TCP OK - %.4f response on port %s"
-CRITICAL_MESSAGE = "Connection failed on host {0}:{1}"
-
-HIVE_SERVER_THRIFT_PORT_KEY = '{{hive-site/hive.server2.thrift.port}}'
-SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
-HIVE_SERVER2_AUTHENTICATION_KEY = '{{hive-site/hive.server2.authentication}}'
-HIVE_SERVER_PRINCIPAL_KEY = 
'{{hive-site/hive.server2.authentication.kerberos.principal}}'
-SMOKEUSER_KEYTAB_KEY = '{{cluster-env/smokeuser_keytab}}'
-SMOKEUSER_KEY = '{{cluster-env/smokeuser}}'
-
-PERCENT_WARNING = 200
-PERCENT_CRITICAL = 200
-
-THRIFT_PORT_DEFAULT = 10000
-HIVE_SERVER_PRINCIPAL_DEFAULT = 'hive/[email protected]'
-HIVE_SERVER2_AUTHENTICATION_DEFAULT = 'NOSASL'
-SMOKEUSER_KEYTAB_DEFAULT = '/etc/security/keytabs/smokeuser.headless.keytab'
-SMOKEUSER_DEFAULT = 'ambari-qa'
-
-def get_tokens():
-  """
-  Returns a tuple of tokens in the format {{site/property}} that will be used
-  to build the dictionary passed into execute
-  """
-  return 
(HIVE_SERVER_THRIFT_PORT_KEY,SECURITY_ENABLED_KEY,HIVE_SERVER2_AUTHENTICATION_KEY,HIVE_SERVER_PRINCIPAL_KEY,SMOKEUSER_KEYTAB_KEY,SMOKEUSER_KEY)
-
-
-def execute(parameters=None, host_name=None):
-  """
-  Returns a tuple containing the result code and a pre-formatted result label
-
-  Keyword arguments:
-  parameters (dictionary): a mapping of parameter key to value
-  host_name (string): the name of this host where the alert is running
-  """
-
-  if parameters is None:
-    return (('UNKNOWN', ['There were no parameters supplied to the script.']))
-
-  thrift_port = THRIFT_PORT_DEFAULT
-  if HIVE_SERVER_THRIFT_PORT_KEY in parameters:
-    thrift_port = int(parameters[HIVE_SERVER_THRIFT_PORT_KEY])
-
-  security_enabled = False
-  if SECURITY_ENABLED_KEY in parameters:
-    security_enabled = str(parameters[SECURITY_ENABLED_KEY]).upper() == 'TRUE'
-
-  hive_server2_authentication = HIVE_SERVER2_AUTHENTICATION_DEFAULT
-  if HIVE_SERVER2_AUTHENTICATION_KEY in parameters:
-    hive_server2_authentication = parameters[HIVE_SERVER2_AUTHENTICATION_KEY]
-
-  smokeuser = SMOKEUSER_DEFAULT
-  if SMOKEUSER_KEY in parameters:
-    smokeuser = parameters[SMOKEUSER_KEY]
-
-  result_code = None
-
-  if security_enabled:
-    hive_server_principal = HIVE_SERVER_PRINCIPAL_DEFAULT
-    if HIVE_SERVER_PRINCIPAL_KEY in parameters:
-      hive_server_principal = parameters[HIVE_SERVER_PRINCIPAL_KEY]
-    smokeuser_keytab = SMOKEUSER_KEYTAB_DEFAULT
-    if SMOKEUSER_KEYTAB_KEY in parameters:
-      smokeuser_keytab = parameters[SMOKEUSER_KEYTAB_KEY]
-    with Environment() as env:
-      kinit_path_local = get_kinit_path(["/usr/bin", "/usr/kerberos/bin", 
"/usr/sbin"])
-      kinitcmd=format("{kinit_path_local} -kt {smokeuser_keytab} {smokeuser}; 
")
-  else:
-    hive_server_principal = None
-    kinitcmd=None
-
-  try:
-    if host_name is None:
-      host_name = socket.getfqdn()
-
-    start_time = time.time()
-    try:
-      with Environment() as env:
-        hive_check.check_thrift_port_sasl(host_name, thrift_port, 
hive_server2_authentication,
-                                          hive_server_principal, kinitcmd, 
smokeuser)
-      is_thrift_port_ok = True
-    except:
-      is_thrift_port_ok = False
-
-    if is_thrift_port_ok == True:
-      result_code = 'OK'
-      total_time = time.time() - start_time
-      label = OK_MESSAGE % (total_time, thrift_port)
-    else:
-      result_code = 'CRITICAL'
-      label = CRITICAL_MESSAGE.format(host_name,thrift_port)
-
-  except Exception, e:
-    label = str(e)
-    result_code = 'UNKNOWN'
-
-  return ((result_code, [label]))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_webhcat_server.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_webhcat_server.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_webhcat_server.py
deleted file mode 100644
index 44840de..0000000
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/HIVE/package/files/alert_webhcat_server.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import json
-import socket
-import time
-import urllib2
-
-RESULT_CODE_OK = 'OK'
-RESULT_CODE_CRITICAL = 'CRITICAL'
-RESULT_CODE_UNKNOWN = 'UNKNOWN'
-
-OK_MESSAGE = 'TCP OK - {0:.4f} response on port {1}'
-CRITICAL_CONNECTION_MESSAGE = 'Connection failed on host {0}:{1}'
-CRITICAL_TEMPLETON_STATUS_MESSAGE = 'WebHCat returned an unexpected status of 
"{0}"'
-CRITICAL_TEMPLETON_UNKNOWN_JSON_MESSAGE = 'Unable to determine WebHCat health 
from unexpected JSON response'
-
-TEMPLETON_PORT_KEY = '{{webhcat-site/templeton.port}}'
-SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
-
-TEMPLETON_OK_RESPONSE = 'ok'
-TEMPLETON_PORT_DEFAULT = 50111
-
-def get_tokens():
-  """
-  Returns a tuple of tokens in the format {{site/property}} that will be used
-  to build the dictionary passed into execute
-  """
-  return (TEMPLETON_PORT_KEY,SECURITY_ENABLED_KEY)      
-  
-
-def execute(parameters=None, host_name=None):
-  """
-  Returns a tuple containing the result code and a pre-formatted result label
-
-  Keyword arguments:
-  parameters (dictionary): a mapping of parameter key to value
-  host_name (string): the name of this host where the alert is running
-  """
-
-  result_code = RESULT_CODE_UNKNOWN
-
-  if parameters is None:
-    return (result_code, ['There were no parameters supplied to the script.'])
-
-  templeton_port = TEMPLETON_PORT_DEFAULT
-  if TEMPLETON_PORT_KEY in parameters:
-    templeton_port = int(parameters[TEMPLETON_PORT_KEY])  
-
-  security_enabled = False
-  if SECURITY_ENABLED_KEY in parameters:
-    security_enabled = parameters[SECURITY_ENABLED_KEY].lower() == 'true'
-
-  scheme = 'http'
-  if security_enabled is True:
-    scheme = 'https'
-
-  label = ''
-  url_response = None
-  templeton_status = ''
-  total_time = 0
-
-  try:
-    # the alert will always run on the webhcat host
-    if host_name is None:
-      host_name = socket.getfqdn()
-    
-    query = "{0}://{1}:{2}/templeton/v1/status".format(scheme, host_name,
-        templeton_port)
-    
-    # execute the query for the JSON that includes templeton status
-    start_time = time.time()
-    url_response = urllib2.urlopen(query)
-    total_time = time.time() - start_time
-  except:
-    label = CRITICAL_CONNECTION_MESSAGE.format(host_name,templeton_port)
-    return (RESULT_CODE_CRITICAL, [label])
-
-  # URL response received, parse it
-  try:
-    json_response = json.loads(url_response.read())
-    templeton_status = json_response['status']
-  except:
-    return (RESULT_CODE_CRITICAL, [CRITICAL_TEMPLETON_UNKNOWN_JSON_MESSAGE])
-
-  # proper JSON received, compare against known value
-  if templeton_status.lower() == TEMPLETON_OK_RESPONSE:
-    result_code = RESULT_CODE_OK
-    label = OK_MESSAGE.format(total_time, templeton_port)
-  else:
-    result_code = RESULT_CODE_CRITICAL
-    label = CRITICAL_TEMPLETON_STATUS_MESSAGE.format(templeton_status)
-
-  return (result_code, [label])
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/alerts.json
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/alerts.json
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/alerts.json
index 9250e14..f192e2c 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/alerts.json
+++ 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/alerts.json
@@ -186,7 +186,7 @@
         "enabled": true,
         "source": {
           "type": "SCRIPT",
-          "path": 
"HDP/1.3.2/services/MAPREDUCE/package/files/alert_mapreduce_directory_space.py"
+          "path": 
"HDP/1.3.2/services/MAPREDUCE/package/alerts/alert_mapreduce_directory_space.py"
         }
       }
     ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/alerts/alert_mapreduce_directory_space.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/alerts/alert_mapreduce_directory_space.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/alerts/alert_mapreduce_directory_space.py
new file mode 100644
index 0000000..d6e5d75
--- /dev/null
+++ 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/alerts/alert_mapreduce_directory_space.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import collections
+import os
+import platform
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+MAPREDUCE_LOCAL_DIR_KEY = '{{mapred-site/mapred.local.dir}}'
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (MAPREDUCE_LOCAL_DIR_KEY,)
+
+
+def execute(parameters=None, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  parameters (dictionary): a mapping of parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+  if parameters is None:
+    return (('UNKNOWN', ['There were no parameters supplied to the script.']))
+
+  if set([MAPREDUCE_LOCAL_DIR_KEY]).issubset(parameters):
+    mapreduce_local_directories = parameters[MAPREDUCE_LOCAL_DIR_KEY]
+  else:
+    return (('UNKNOWN', ['The MapReduce Local Directory is required.']))
+
+  directory_list = mapreduce_local_directories.split(",")
+  for directory in directory_list:
+    disk_usage = None
+    try:
+      disk_usage = _get_disk_usage(directory)
+    except NotImplementedError, platform_error:
+      return (RESULT_CODE_UNKNOWN, [str(platform_error)])
+
+    if disk_usage is None or disk_usage.total == 0:
+      return (RESULT_CODE_UNKNOWN, ['Unable to determine the disk usage.'])
+
+    percent = disk_usage.used / float(disk_usage.total) * 100
+
+    if percent > 85:
+      message = 'The disk usage of {0} is {1:d}%'.format(directory,percent)
+      return (RESULT_CODE_CRITICAL, [message])
+
+  return (RESULT_CODE_OK, ["All MapReduce local directories have sufficient 
space."])
+
+
+def _get_disk_usage(path):
+  """
+  returns a named tuple that contains the total, used, and free disk space
+  in bytes
+  """
+  used = 0
+  total = 0
+  free = 0
+
+  if 'statvfs' in dir(os):
+    disk_stats = os.statvfs(path)
+    free = disk_stats.f_bavail * disk_stats.f_frsize
+    total = disk_stats.f_blocks * disk_stats.f_frsize
+    used = (disk_stats.f_blocks - disk_stats.f_bfree) * disk_stats.f_frsize
+  else:
+    raise NotImplementedError("{0} is not a supported platform for this 
alert".format(platform.platform()))
+
+  DiskInfo = collections.namedtuple('DiskInfo', 'total used free')
+  return DiskInfo(total=total, used=used, free=free)

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/files/alert_mapreduce_directory_space.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/files/alert_mapreduce_directory_space.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/files/alert_mapreduce_directory_space.py
deleted file mode 100644
index 2124ad1..0000000
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/MAPREDUCE/package/files/alert_mapreduce_directory_space.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import collections
-import os
-import platform
-
-RESULT_CODE_OK = 'OK'
-RESULT_CODE_CRITICAL = 'CRITICAL'
-RESULT_CODE_UNKNOWN = 'UNKNOWN'
-
-MAPREDUCE_LOCAL_DIR_KEY = '{{mapred-site/mapred.local.dir}}'
-
-def get_tokens():
-  """
-  Returns a tuple of tokens in the format {{site/property}} that will be used
-  to build the dictionary passed into execute
-  """
-  return (MAPREDUCE_LOCAL_DIR_KEY,)
-  
-
-def execute(parameters=None, host_name=None):
-  """
-  Returns a tuple containing the result code and a pre-formatted result label
-
-  Keyword arguments:
-  parameters (dictionary): a mapping of parameter key to value
-  host_name (string): the name of this host where the alert is running
-  """
-  if parameters is None:
-    return (('UNKNOWN', ['There were no parameters supplied to the script.']))
-
-  mapreduce_local_directories = None
-  if MAPREDUCE_LOCAL_DIR_KEY in parameters:
-    mapreduce_local_directories = parameters[MAPREDUCE_LOCAL_DIR_KEY]
-
-  if MAPREDUCE_LOCAL_DIR_KEY is None:
-    return (('UNKNOWN', ['The MapReduce Local Directory is required.']))
-
-  directory_list = mapreduce_local_directories.split(",")
-  for directory in directory_list:
-    disk_usage = None
-    try:
-      disk_usage = _get_disk_usage(directory)
-    except NotImplementedError, platform_error:
-      return (RESULT_CODE_UNKNOWN, [str(platform_error)])
-
-    if disk_usage is None or disk_usage.total == 0:
-      return (RESULT_CODE_UNKNOWN, ['Unable to determine the disk usage.'])
-
-    percent = disk_usage.used / float(disk_usage.total) * 100
-
-    if percent > 85:
-      message = 'The disk usage of {0} is {1:d}%'.format(directory,percent)
-      return (RESULT_CODE_CRITICAL, [message])
-
-  return (RESULT_CODE_OK, ["All MapReduce local directories have sufficient 
space."])
-
-
-def _get_disk_usage(path):
-  """
-  returns a named tuple that contains the total, used, and free disk space
-  in bytes
-  """
-  used = 0
-  total = 0
-  free = 0
-  
-  if 'statvfs' in dir(os):
-    disk_stats = os.statvfs(path)
-    free = disk_stats.f_bavail * disk_stats.f_frsize
-    total = disk_stats.f_blocks * disk_stats.f_frsize
-    used = (disk_stats.f_blocks - disk_stats.f_bfree) * disk_stats.f_frsize
-  else:
-    raise NotImplementedError("{0} is not a supported platform for this 
alert".format(platform.platform()))
-  
-  DiskInfo = collections.namedtuple('DiskInfo', 'total used free')
-  return DiskInfo(total=total, used=used, free=free)

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/alerts.json
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/alerts.json 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/alerts.json
index 8a1646b..df8ab0f 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/alerts.json
+++ 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/alerts.json
@@ -34,7 +34,7 @@
         "scope": "ANY",
         "source": {
           "type": "SCRIPT",
-          "path": 
"HDP/1.3.2/services/OOZIE/package/files/alert_check_oozie_server.py"
+          "path": 
"HDP/1.3.2/services/OOZIE/package/alerts/alert_check_oozie_server.py"
         }
       }
     ]

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/alerts/alert_check_oozie_server.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/alerts/alert_check_oozie_server.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/alerts/alert_check_oozie_server.py
new file mode 100644
index 0000000..4e3e6ae
--- /dev/null
+++ 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/alerts/alert_check_oozie_server.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import *
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions import get_kinit_path
+from resource_management.core.environment import Environment
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+OOZIE_URL_KEY = '{{oozie-site/oozie.base.url}}'
+SECURITY_ENABLED = '{{cluster-env/security_enabled}}'
+SMOKEUSER_KEY = '{{cluster-env/smokeuser}}'
+SMOKEUSER_KEYTAB_KEY = '{{cluster-env/smokeuser_keytab}}'
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (OOZIE_URL_KEY, SMOKEUSER_KEY, SECURITY_ENABLED,SMOKEUSER_KEYTAB_KEY)
+
+def execute(parameters=None, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  parameters (dictionary): a mapping of parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+
+  if parameters is None:
+    return (RESULT_CODE_UNKNOWN, ['There were no parameters supplied to the 
script.'])
+
+  security_enabled = False
+  if set([OOZIE_URL_KEY, SMOKEUSER_KEY, 
SECURITY_ENABLED]).issubset(parameters):
+    oozie_url = parameters[OOZIE_URL_KEY]
+    smokeuser = parameters[SMOKEUSER_KEY]
+    security_enabled = str(parameters[SECURITY_ENABLED]).upper() == 'TRUE'
+  else:
+    return (RESULT_CODE_UNKNOWN, ['The Oozie URL and Smokeuser are a required 
parameters.'])
+
+  try:
+    if security_enabled:
+      if set([SMOKEUSER_KEYTAB_KEY]).issubset(parameters):
+        smokeuser_keytab = parameters[SMOKEUSER_KEYTAB_KEY]
+      else:
+        return (RESULT_CODE_UNKNOWN, ['The Smokeuser keytab is required when 
security is enabled.'])
+      kinit_path_local = get_kinit_path(["/usr/bin", "/usr/kerberos/bin", 
"/usr/sbin"])
+      kinitcmd = format("{kinit_path_local} -kt {smokeuser_keytab} 
{smokeuser}; ")
+
+      Execute(kinitcmd,
+              user=smokeuser,
+              )
+
+    Execute(format("source /etc/oozie/conf/oozie-env.sh ; oozie admin -oozie 
{oozie_url} -status"),
+            user=smokeuser,
+            )
+    return (RESULT_CODE_OK, ["Oozie check success"])
+
+  except Exception, ex:
+    return (RESULT_CODE_CRITICAL, [str(ex)])

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/files/alert_check_oozie_server.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/files/alert_check_oozie_server.py
 
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/files/alert_check_oozie_server.py
deleted file mode 100644
index 7bf1255..0000000
--- 
a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/OOZIE/package/files/alert_check_oozie_server.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import subprocess
-from subprocess import CalledProcessError
-
-RESULT_CODE_OK = 'OK'
-RESULT_CODE_CRITICAL = 'CRITICAL'
-RESULT_CODE_UNKNOWN = 'UNKNOWN'
-
-OOZIE_URL_KEY = '{{oozie-site/oozie.base.url}}'
-
-def get_tokens():
-  """
-  Returns a tuple of tokens in the format {{site/property}} that will be used
-  to build the dictionary passed into execute
-  """
-  return (OOZIE_URL_KEY)
-  
-
-def execute(parameters=None, host_name=None):
-  """
-  Returns a tuple containing the result code and a pre-formatted result label
-
-  Keyword arguments:
-  parameters (dictionary): a mapping of parameter key to value
-  host_name (string): the name of this host where the alert is running
-  """
-
-  if parameters is None:
-    return (RESULT_CODE_UNKNOWN, ['There were no parameters supplied to the 
script.'])
-
-  oozie_url = None
-  if OOZIE_URL_KEY in parameters:
-    oozie_url = parameters[OOZIE_URL_KEY]
-
-  if oozie_url is None:
-    return (RESULT_CODE_UNKNOWN, ['The Oozie URL is a required parameter.'])
-
-  try:
-    # oozie admin -oozie http://server:11000/oozie -status
-    oozie_process = subprocess.Popen(['oozie', 'admin', '-oozie',
-      oozie_url, '-status'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
-
-    oozie_output, oozie_error = oozie_process.communicate()
-    oozie_return_code = oozie_process.returncode
-
-    if oozie_return_code == 0:
-      # strip trailing newlines
-      oozie_output = str(oozie_output).strip('\n')
-      return (RESULT_CODE_OK, [oozie_output])
-    else:
-      oozie_error = str(oozie_error).strip('\n')
-      return (RESULT_CODE_CRITICAL, [oozie_error])
-
-  except CalledProcessError, cpe:
-    return (RESULT_CODE_CRITICAL, [str(cpe)])

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/alerts.json
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/alerts.json 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/alerts.json
index d4a2076..32dc474 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/alerts.json
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/alerts.json
@@ -199,7 +199,7 @@
         "enabled": true,
         "source": {
           "type": "SCRIPT",
-          "path": 
"HDP/2.0.6/services/YARN/package/files/alert_nodemanager_health.py"
+          "path": 
"HDP/2.0.6/services/YARN/package/alerts/alert_nodemanager_health.py"
         }
       }
     ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/alerts/alert_nodemanager_health.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/alerts/alert_nodemanager_health.py
 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/alerts/alert_nodemanager_health.py
new file mode 100644
index 0000000..b1de951
--- /dev/null
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/alerts/alert_nodemanager_health.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import json
+import socket
+import urllib2
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+NODEMANAGER_HTTP_ADDRESS_KEY = '{{yarn-site/yarn.nodemanager.webapp.address}}'
+NODEMANAGER_HTTPS_ADDRESS_KEY = 
'{{yarn-site/yarn.nodemanager.webapp.https.address}}'
+YARN_HTTP_POLICY_KEY = '{{yarn-site/yarn.http.policy}}'
+
+OK_MESSAGE = 'NodeManager Healthy'
+CRITICAL_CONNECTION_MESSAGE = 'Connection failed to {0}'
+CRITICAL_NODEMANAGER_STATUS_MESSAGE = 'NodeManager returned an unexpected 
status of "{0}"'
+CRITICAL_NODEMANAGER_UNKNOWN_JSON_MESSAGE = 'Unable to determine NodeManager 
health from unexpected JSON response'
+
+NODEMANAGER_DEFAULT_PORT = 8042
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (NODEMANAGER_HTTP_ADDRESS_KEY,NODEMANAGER_HTTPS_ADDRESS_KEY,
+  YARN_HTTP_POLICY_KEY)
+  
+
+def execute(parameters=None, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  parameters (dictionary): a mapping of parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+  result_code = RESULT_CODE_UNKNOWN
+
+  if parameters is None:
+    return (result_code, ['There were no parameters supplied to the script.'])
+
+  scheme = 'http'
+  http_uri = None
+  https_uri = None
+  http_policy = 'HTTP_ONLY'
+
+  if NODEMANAGER_HTTP_ADDRESS_KEY in parameters:
+    http_uri = parameters[NODEMANAGER_HTTP_ADDRESS_KEY]
+
+  if NODEMANAGER_HTTPS_ADDRESS_KEY in parameters:
+    https_uri = parameters[NODEMANAGER_HTTPS_ADDRESS_KEY]
+
+  if YARN_HTTP_POLICY_KEY in parameters:
+    http_policy = parameters[YARN_HTTP_POLICY_KEY]
+
+  # determine the right URI and whether to use SSL
+  uri = http_uri
+  if http_policy == 'HTTPS_ONLY':
+    scheme = 'https'
+
+    if https_uri is not None:
+      uri = https_uri
+
+  label = ''
+  url_response = None
+  node_healthy = 'false'
+  total_time = 0
+
+  # some yarn-site structures don't have the web ui address
+  if uri is None:
+    if host_name is None:
+      host_name = socket.getfqdn()
+
+    uri = '{0}:{1}'.format(host_name, NODEMANAGER_DEFAULT_PORT)
+
+  try:
+    query = "{0}://{1}/ws/v1/node/info".format(scheme,uri)
+    
+    # execute the query for the JSON that includes templeton status
+    url_response = urllib2.urlopen(query)
+  except:
+    label = CRITICAL_CONNECTION_MESSAGE.format(uri)
+    return (RESULT_CODE_CRITICAL, [label])
+
+  # URL response received, parse it
+  try:
+    json_response = json.loads(url_response.read())
+    node_healthy = json_response['nodeInfo']['nodeHealthy']
+
+    # convert boolean to string
+    node_healthy = str(node_healthy)
+  except:
+    return (RESULT_CODE_CRITICAL, [query])
+
+  # proper JSON received, compare against known value
+  if node_healthy.lower() == 'true':
+    result_code = RESULT_CODE_OK
+    label = OK_MESSAGE
+  else:
+    result_code = RESULT_CODE_CRITICAL
+    label = CRITICAL_NODEMANAGER_STATUS_MESSAGE.format(node_healthy)
+
+  return (result_code, [label])

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec37c603/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/files/alert_nodemanager_health.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/files/alert_nodemanager_health.py
 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/files/alert_nodemanager_health.py
deleted file mode 100644
index b1de951..0000000
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/files/alert_nodemanager_health.py
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import json
-import socket
-import urllib2
-
-RESULT_CODE_OK = 'OK'
-RESULT_CODE_CRITICAL = 'CRITICAL'
-RESULT_CODE_UNKNOWN = 'UNKNOWN'
-
-NODEMANAGER_HTTP_ADDRESS_KEY = '{{yarn-site/yarn.nodemanager.webapp.address}}'
-NODEMANAGER_HTTPS_ADDRESS_KEY = 
'{{yarn-site/yarn.nodemanager.webapp.https.address}}'
-YARN_HTTP_POLICY_KEY = '{{yarn-site/yarn.http.policy}}'
-
-OK_MESSAGE = 'NodeManager Healthy'
-CRITICAL_CONNECTION_MESSAGE = 'Connection failed to {0}'
-CRITICAL_NODEMANAGER_STATUS_MESSAGE = 'NodeManager returned an unexpected 
status of "{0}"'
-CRITICAL_NODEMANAGER_UNKNOWN_JSON_MESSAGE = 'Unable to determine NodeManager 
health from unexpected JSON response'
-
-NODEMANAGER_DEFAULT_PORT = 8042
-
-def get_tokens():
-  """
-  Returns a tuple of tokens in the format {{site/property}} that will be used
-  to build the dictionary passed into execute
-  """
-  return (NODEMANAGER_HTTP_ADDRESS_KEY,NODEMANAGER_HTTPS_ADDRESS_KEY,
-  YARN_HTTP_POLICY_KEY)
-  
-
-def execute(parameters=None, host_name=None):
-  """
-  Returns a tuple containing the result code and a pre-formatted result label
-
-  Keyword arguments:
-  parameters (dictionary): a mapping of parameter key to value
-  host_name (string): the name of this host where the alert is running
-  """
-  result_code = RESULT_CODE_UNKNOWN
-
-  if parameters is None:
-    return (result_code, ['There were no parameters supplied to the script.'])
-
-  scheme = 'http'
-  http_uri = None
-  https_uri = None
-  http_policy = 'HTTP_ONLY'
-
-  if NODEMANAGER_HTTP_ADDRESS_KEY in parameters:
-    http_uri = parameters[NODEMANAGER_HTTP_ADDRESS_KEY]
-
-  if NODEMANAGER_HTTPS_ADDRESS_KEY in parameters:
-    https_uri = parameters[NODEMANAGER_HTTPS_ADDRESS_KEY]
-
-  if YARN_HTTP_POLICY_KEY in parameters:
-    http_policy = parameters[YARN_HTTP_POLICY_KEY]
-
-  # determine the right URI and whether to use SSL
-  uri = http_uri
-  if http_policy == 'HTTPS_ONLY':
-    scheme = 'https'
-
-    if https_uri is not None:
-      uri = https_uri
-
-  label = ''
-  url_response = None
-  node_healthy = 'false'
-  total_time = 0
-
-  # some yarn-site structures don't have the web ui address
-  if uri is None:
-    if host_name is None:
-      host_name = socket.getfqdn()
-
-    uri = '{0}:{1}'.format(host_name, NODEMANAGER_DEFAULT_PORT)
-
-  try:
-    query = "{0}://{1}/ws/v1/node/info".format(scheme,uri)
-    
-    # execute the query for the JSON that includes templeton status
-    url_response = urllib2.urlopen(query)
-  except:
-    label = CRITICAL_CONNECTION_MESSAGE.format(uri)
-    return (RESULT_CODE_CRITICAL, [label])
-
-  # URL response received, parse it
-  try:
-    json_response = json.loads(url_response.read())
-    node_healthy = json_response['nodeInfo']['nodeHealthy']
-
-    # convert boolean to string
-    node_healthy = str(node_healthy)
-  except:
-    return (RESULT_CODE_CRITICAL, [query])
-
-  # proper JSON received, compare against known value
-  if node_healthy.lower() == 'true':
-    result_code = RESULT_CODE_OK
-    label = OK_MESSAGE
-  else:
-    result_code = RESULT_CODE_CRITICAL
-    label = CRITICAL_NODEMANAGER_STATUS_MESSAGE.format(node_healthy)
-
-  return (result_code, [label])

Reply via email to