Updated Branches: refs/heads/trunk 52e689237 -> ceb2fc412
AMBARI-3104. Nagios check for namenode edit logs fails in secure http mode. (swagle) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/ceb2fc41 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/ceb2fc41 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/ceb2fc41 Branch: refs/heads/trunk Commit: ceb2fc41299cf172b898a02a2581d55a1109ffe3 Parents: 52e6892 Author: Siddharth Wagle <[email protected]> Authored: Thu Sep 5 14:25:42 2013 -0700 Committer: Siddharth Wagle <[email protected]> Committed: Thu Sep 5 14:25:42 2013 -0700 ---------------------------------------------------------------------- .../hdp-nagios/files/check_name_dir_status.php | 9 ++++++++- .../hdp-nagios/files/check_nodemanager_health.sh | 14 +++++++++++++- .../hdp-nagios/templates/hadoop-services.cfg.erb | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ceb2fc41/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_name_dir_status.php ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_name_dir_status.php b/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_name_dir_status.php index db2b491..a810db1 100644 --- a/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_name_dir_status.php +++ b/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_name_dir_status.php @@ -32,7 +32,14 @@ $port=$options['p']; /* Get the json document */ - $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo"); + $ch = curl_init(); + $username = rtrim(`id -un`, "\n"); + curl_setopt_array($ch, array( CURLOPT_URL => "http://".$host.":".$port."/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_USERPWD => "$username:" )); + $json_string = curl_exec($ch); + curl_close($ch); $json_array = json_decode($json_string, true); $object = $json_array['beans'][0]; if ($object['NameDirStatuses'] == "") { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ceb2fc41/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_nodemanager_health.sh ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_nodemanager_health.sh b/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_nodemanager_health.sh index 82b8a3d..020b41d 100644 --- a/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_nodemanager_health.sh +++ b/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_nodemanager_health.sh @@ -22,8 +22,20 @@ HOST=$1 PORT=$2 NODEMANAGER_URL="http://$HOST:$PORT/ws/v1/node/info" +SEC_ENABLED=$3 export PATH="/usr/bin:$PATH" -RESPONSE=`curl -s $NODEMANAGER_URL` +if [[ "$SEC_ENABLED" == "true" ]]; then + NAGIOS_KEYTAB=$4 + NAGIOS_USER=$5 + KINIT_PATH=$6 + out1=`${KINIT_PATH} -kt ${NAGIOS_KEYTAB} ${NAGIOS_USER} 2>&1` + if [[ "$?" -ne 0 ]]; then + echo "CRITICAL: Error doing kinit for nagios [$out1]"; + exit 2; + fi +fi + +RESPONSE=`curl --negotiate -u : -s $NODEMANAGER_URL` if [[ "$RESPONSE" == *'"nodeHealthy":true'* ]]; then echo "OK: NodeManager healthy"; exit 0; http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ceb2fc41/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb b/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb index 4f50b67..b8ee10f 100644 --- a/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb +++ b/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb @@ -516,7 +516,7 @@ define service { use hadoop-service service_description NODEMANAGER::NodeManager health servicegroups YARN - check_command check_nodemanager_health!<%=scope.function_hdp_template_var("nm_port")%> + check_command check_nodemanager_health!<%=scope.function_hdp_template_var("nm_port")%>!<%=scope.function_hdp_template_var("::hdp::params::security_enabled")%>!<%=scope.function_hdp_template_var("nagios_keytab_path")%>!<%=scope.function_hdp_template_var("nagios_principal_name")%>!<%=scope.function_hdp_template_var("kinit_path_local")%> normal_check_interval 1 retry_check_interval 1 max_check_attempts 3 @@ -720,7 +720,7 @@ define service { service_description WEBHCAT::WebHCat Server status servicegroups WEBHCAT <%if scope.function_hdp_template_var("::hdp::params::security_enabled")-%> - check_command check_templeton_status!<%=scope.function_hdp_template_var("::hdp::templeton_port")%>!v1!true!<%=scope.function_hdp_template_var("nagios_keytab_path")%>!<%=scope.function_hdp_template_var("nagios_principal_name")%>!<%=scope.function_hdp_template_var("kinit_path_local")%> + check_command check_templeton_status!<%=scope.function_hdp_template_var("::hdp::templeton_port")%>!v1!<%=scope.function_hdp_template_var("::hdp::params::security_enabled")%>!<%=scope.function_hdp_template_var("nagios_keytab_path")%>!<%=scope.function_hdp_template_var("nagios_principal_name")%>!<%=scope.function_hdp_template_var("kinit_path_local")%> <%else-%> check_command check_templeton_status!<%=scope.function_hdp_template_var("::hdp::templeton_port")%>!v1!false <%end-%>
