You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/10/15 07:55:57 UTC

svn commit: r1398196 [7/11] - in /incubator/ambari/branches/branch-0.9-h2-dev: ./ hmc/js/ hmc/package/rpm/ hmc/php/conf/ hmc/php/db/ hmc/php/frontend/ hmc/php/orchestrator/ hmc/php/puppet/ hmc/php/puppet/genmanifest/ hmc/php/util/ hmc/puppet/modules/hd...

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_cpu.pl
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_cpu.pl?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_cpu.pl (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_cpu.pl Mon Oct 15 05:55:46 2012
@@ -0,0 +1,114 @@
+#!/usr/bin/perl -w 
+#
+#
+# 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.
+#
+#
+use strict;
+use Net::SNMP;
+use Getopt::Long;
+
+# Variable
+my $base_proc = "1.3.6.1.2.1.25.3.3.1";   
+my $proc_load = "1.3.6.1.2.1.25.3.3.1.2"; 
+my $o_host = 	undef;
+my $o_community = undef;
+my $o_warn=	undef;
+my $o_crit=	undef;
+my $o_timeout = 15;
+my $o_port = 161;
+
+sub Usage {
+    print "Usage: $0 -H <host> -C <snmp_community> -w <warn level> -c <crit level>\n";
+}
+
+Getopt::Long::Configure ("bundling");
+GetOptions(
+  'H:s'   => \$o_host,	
+  'C:s'   => \$o_community,	
+  'c:s'   => \$o_crit,        
+  'w:s'   => \$o_warn
+          );
+if (!defined $o_host || !defined $o_community || !defined $o_crit || !defined $o_warn) {
+  Usage();
+  exit 3;
+}
+$o_warn =~ s/\%//g; 
+$o_crit =~ s/\%//g;
+alarm ($o_timeout);
+$SIG{'ALRM'} = sub {
+ print "Unable to contact host: $o_host\n";
+ exit 3;
+};
+
+# Connect to host
+my ($session,$error);
+($session, $error) = Net::SNMP->session(
+		-hostname  => $o_host,
+		-community => $o_community,
+		-port      => $o_port,
+		-timeout   => $o_timeout
+	  );
+if (!defined($session)) {
+   printf("Error opening session: %s.\n", $error);
+   exit 3;
+}
+
+my $exit_val=undef;
+my $resultat =  (Net::SNMP->VERSION < 4) ?
+	  $session->get_table($base_proc)
+	: $session->get_table(Baseoid => $base_proc);
+
+if (!defined($resultat)) {
+   printf("ERROR: Description table : %s.\n", $session->error);
+   $session->close;
+   exit 3;
+}
+
+$session->close;
+
+my ($cpu_used,$ncpu)=(0,0);
+foreach my $key ( keys %$resultat) {
+  if ($key =~ /$proc_load/) {
+    $cpu_used += $$resultat{$key};
+    $ncpu++;
+  }
+}
+
+if ($ncpu==0) {
+  print "Can't find CPU usage information : UNKNOWN\n";
+  exit 3;
+}
+
+$cpu_used /= $ncpu;
+
+print "$ncpu CPU, ", $ncpu==1 ? "load" : "average load";
+printf(" %.1f%%",$cpu_used);
+$exit_val=0;
+
+if ($cpu_used > $o_crit) {
+ print " > $o_crit% : CRITICAL\n";
+ $exit_val=2;
+} else {
+  if ($cpu_used > $o_warn) {
+   print " > $o_warn% : WARNING\n";
+   $exit_val=1;
+  }
+}
+print " < $o_warn% : OK\n" if ($exit_val eq 0);
+exit $exit_val;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_datanode_storage.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_datanode_storage.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_datanode_storage.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_datanode_storage.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,63 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to master node, get the jmx-json document
+ * check the storage capacity remaining on local datanode storage
+ */
+
+  $options = getopt ("h:p:w:c:");
+  if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options) 
+      || !array_key_exists('c', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+  $port=$options['p'];
+  $warn=$options['w']; $warn = preg_replace('/%$/', '', $warn);
+  $crit=$options['c']; $crit = preg_replace('/%$/', '', $crit);
+
+  /* Get the json document */
+  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=DataNode,name=FSDatasetState-DS-*");
+  $json_array = json_decode($json_string, true);
+  $object = $json_array['beans'][0];
+  $cap_remain = $object['Remaining']; /* Total capacity - any extenal files created in data directories by non-hadoop app */
+  $cap_total = $object['Capacity']; /* Capacity used by all data partitions minus space reserved for M/R */
+  $percent_full = ($cap_total - $cap_remain)/$cap_total * 100;
+
+  $out_msg = "Capacity:[" . $cap_total . 
+             "], Remaining Capacity:[" . $cap_remain . 
+             "], percent_full:[" . $percent_full  . "]";
+  
+  if ($percent_full > $crit) {
+    echo "CRITICAL: " . $out_msg . "\n";
+    exit (2);
+  }
+  if ($percent_full > $warn) {
+    echo "WARNING: " . $out_msg . "\n";
+    exit (1);
+  }
+  echo "OK: " . $out_msg . "\n";
+  exit(0);
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host> -p port -w <warn%> -c <crit%>\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_blocks.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_blocks.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_blocks.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_blocks.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,72 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to master node, get the jmx-json document
+ * check the corrupt or missing blocks % is > threshod
+ * check_jmx -H hostaddress -p port -w 1% -c 1%
+ */
+
+  $options = getopt ("h:p:w:c:");
+  if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options)
+      || !array_key_exists('c', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+  $port=$options['p'];
+  $warn=$options['w']; $warn = preg_replace('/%$/', '', $warn);
+  $crit=$options['c']; $crit = preg_replace('/%$/', '', $crit);
+
+  /* Get the json document */
+  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemMetrics");
+  $json_array = json_decode($json_string, true);
+  $m_percent = 0;
+  $c_percent = 0;
+  $object = $json_array['beans'][0];
+  $missing_blocks = $object['MissingBlocks'];
+  $corrupt_blocks = $object['CorruptBlocks'];
+  $total_blocks = $object['BlocksTotal'];
+  if($total_blocks == 0) {
+    $m_percent = 0;
+    $c_percent = 0;
+  } else {
+    $m_percent = ($missing_blocks/$total_blocks)*100;
+    $c_percent = ($corrupt_blocks/$total_blocks)*100;
+  }
+  $out_msg = "corrupt_blocks:<" . $corrupt_blocks .
+             ">, missing_blocks:<" . $missing_blocks .
+             ">, total_blocks:<" . $total_blocks . ">";
+
+  if ($m_percent > $crit || $c_percent > $crit) {
+    echo "CRITICAL: " . $out_msg . "\n";
+    exit (2);
+  }
+  if ($m_percent > $warn || $c_percent > $warn) {
+    echo "WARNING: " . $out_msg . "\n";
+    exit (1);
+  }
+  echo "OK: " . $out_msg . "\n";
+  exit(0);
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host> -p port -w <warn%> -c <crit%>\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_capacity.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_capacity.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_capacity.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hdfs_capacity.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,68 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to master node, get the jmx-json document
+ * check the % HDFS capacity used >= warn and critical limits.
+ * check_jmx -H hostaddress -p port -w 1 -c 1
+ */
+
+  $options = getopt ("h:p:w:c:");
+  if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options)
+      || !array_key_exists('c', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+  $port=$options['p'];
+  $warn=$options['w']; $warn = preg_replace('/%$/', '', $warn);
+  $crit=$options['c']; $crit = preg_replace('/%$/', '', $crit);
+
+  /* Get the json document */
+  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState");
+  $json_array = json_decode($json_string, true);
+  $percent = 0;
+  $object = $json_array['beans'][0];
+  $CapacityUsed = $object['CapacityUsed'];
+  $CapacityRemaining = $object['CapacityRemaining'];
+  $CapacityTotal = $CapacityUsed + $CapacityRemaining;
+  if($CapacityTotal == 0) {
+    $percent = 0;
+  } else {
+    $percent = ($CapacityUsed/$CapacityTotal)*100;
+  }
+  $out_msg = "DFSUsedGB:<" . round ($CapacityUsed/(1024*1024*1024),1) .
+             ">, DFSTotalGB:<" . round($CapacityTotal/(1024*1024*1024),1) . ">";
+
+  if ($percent >= $crit) {
+    echo "CRITICAL: " . $out_msg . "\n";
+    exit (2);
+  }
+  if ($percent >= $warn) {
+    echo "WARNING: " . $out_msg . "\n";
+    exit (1);
+  }
+  echo "OK: " . $out_msg . "\n";
+  exit(0);
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host> -p port -w <warn%> -c <crit%>\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hive_metastore_status.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hive_metastore_status.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hive_metastore_status.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_hive_metastore_status.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+#
+#
+# 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.
+#
+#
+#The uri is of the form thrift://<hostname>:<port>
+HOST=$1
+PORT=$2
+HCAT_URL=-Dhive.metastore.uris="thrift://$HOST:$PORT"
+out=`hcat $HCAT_URL -e "show databases" 2>&1`
+if [[ "$?" -ne 0 ]]; then 
+  echo "CRITICAL: Error accessing hive-metaserver status [$out]";
+  exit 2;
+fi
+echo "OK: Hive metaserver status OK";
+exit 0;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_name_dir_status.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_name_dir_status.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_name_dir_status.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_name_dir_status.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,59 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to namenode, get the jmx-json document
+ * check the NameDirStatuses to find any offline (failed) directories
+ * check_jmx -H hostaddress -p port
+ */
+
+  $options = getopt ("h:p:");
+  if (!array_key_exists('h', $options) || !array_key_exists('p', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+  $port=$options['p'];
+
+  /* Get the json document */
+  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo");
+  $json_array = json_decode($json_string, true);
+  $object = $json_array['beans'][0];
+  if ($object['NameDirStatuses'] == "") {
+    echo "UNKNOWN: Namenode directory status not available via http://<nn_host>:port/jmx url" . "\n";
+    exit(3);
+  }
+  $NameDirStatuses = json_decode($object['NameDirStatuses'], true);
+  $failed_dir_count = count($NameDirStatuses['failed']);
+  $out_msg = "CRITICAL: Offline Namenode directories: ";
+  if ($failed_dir_count > 0) {
+    foreach ($NameDirStatuses['failed'] as $key => $value) {
+      $out_msg = $out_msg . $key . ":" . $value . ", ";
+    }
+    echo $out_msg . "\n";
+    exit (2);
+  }
+  echo "OK: All Namenode directories are active" . "\n";
+  exit(0);
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host> -p port\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_oozie_status.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_oozie_status.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_oozie_status.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_oozie_status.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,34 @@
+#
+#
+# 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.
+#
+#
+#!/usr/bin/env bash
+# OOZIE_URL is of the form http://<hostname>:<port>/oozie
+HOST=$1
+PORT=$2
+JAVA_HOME=$3
+OOZIE_URL="http://$HOST:$PORT/oozie"
+export JAVA_HOME=$JAVA_HOME
+out=`oozie admin -oozie ${OOZIE_URL} -status 2>&1`
+if [[ "$?" -ne 0 ]]; then 
+  echo "CRITICAL: Error accessing oozie server status [$out]";
+  exit 2;
+fi
+echo "OK: Oozie server status [$out]";
+exit 0;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_puppet_agent_status.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_puppet_agent_status.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_puppet_agent_status.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_puppet_agent_status.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,59 @@
+<?php
+/*
+ * 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.
+ */
+
+ /* This plugin check if puppet agent is alive */
+
+  $options = getopt ("h:");
+  if (!array_key_exists('h', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+
+  /* Give puppet kick --ping to check if agent is working */
+  $out_arr = array();
+  $cmd = "puppet kick -f --host $host --ping 2>/dev/null";
+  exec ($cmd, $out_arr, $err);
+  if ($err == 0 && check_error($out_arr, "status is success", 0) == 0) {
+    // success
+    echo "OK: Puppet agent is active on [$host]" . "\n";
+    exit(0);
+  } else {
+    // Fail
+    echo "WARN: Puppet agent is down on [$host]" . "\n";
+    exit(1);
+  }
+
+  /* check error function */
+  function check_error ($output, $pattern, $ret) {
+    $ret1=($ret+1)%2;
+    for ($i=0; $i<count($output); $i++) {
+      if (preg_match ("/$pattern/", $output[$i])) {
+        return $ret;
+      }
+    }
+    return $ret1;
+  }
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host>\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_rpcq_latency.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_rpcq_latency.php?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_rpcq_latency.php (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_rpcq_latency.php Mon Oct 15 05:55:46 2012
@@ -0,0 +1,67 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to master node, get the jmx-json document
+ * It checks the rpc wait time in the queue, RpcQueueTime_avg_time
+ * check_rpcq_latency -h hostaddress -p port -t ServiceName -w 1 -c 1
+ * Warning and Critical values are in seconds
+ * Service Name = JobTracker, ResourceManager, NameNode
+ */
+
+  $options = getopt ("h:p:w:c:n:");
+  if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options)
+      || !array_key_exists('c', $options) || !array_key_exists('n', $options)) {
+    usage();
+    exit(3);
+  }
+
+  $host=$options['h'];
+  $port=$options['p'];
+  $master=$options['n'];
+  $warn=$options['w'];
+  $crit=$options['c'];
+
+  /* Get the json document */
+  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=".$master.",name=RpcActivityForPort*");
+  $json_array = json_decode($json_string, true);
+  $object = $json_array['beans'][0];
+
+  $RpcQueueTime_avg_time = round($object['RpcQueueTime_avg_time'], 2); 
+  $RpcProcessingTime_avg_time = round($object['RpcProcessingTime_avg_time'], 2);
+
+  $out_msg = "RpcQueueTime_avg_time:<" . $RpcQueueTime_avg_time .
+             "> Secs, RpcProcessingTime_avg_time:<" . $RpcProcessingTime_avg_time .
+             "> Secs";
+
+  if ($RpcQueueTime_avg_time >= $crit) {
+    echo "CRITICAL: " . $out_msg . "\n";
+    exit (2);
+  }
+  if ($RpcQueueTime_avg_time >= $warn) {
+    echo "WARNING: " . $out_msg . "\n";
+    exit (1);
+  }
+  echo "OK: " . $out_msg . "\n";
+  exit(0);
+
+  /* print usage */
+  function usage () {
+    echo "Usage: $0 -h <host> -p port -n <JobTracker/ResourceManager/NameNode> -w <warn_in_sec> -c <crit_in_sec>\n";
+  }
+?>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_templeton_status.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_templeton_status.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_templeton_status.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_templeton_status.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+#
+#
+# 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.
+#
+#
+# out='{"status":"ok","version":"v1"}<status_code:200>'
+HOST=$1
+PORT=$2
+VERSION=$3
+regex="^.*\"status\":\"ok\".*<status_code:200>$"
+out=`curl http://$HOST:$PORT/templeton/$VERSION/status -w '<status_code:%{http_code}>' 2>&1`
+if [[ $out =~ $regex ]]; then 
+  echo "OK: Templeton server status [$out]";
+  exit 0;
+fi
+echo "CRITICAL: Error accessing Templeton server, status [$out]";
+exit 2;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_webui.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_webui.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_webui.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/files/check_webui.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+#
+# 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.
+#
+#
+checkurl () {
+  url=$1
+  curl $url -o /dev/null
+  echo $?
+}
+
+service=$1
+host=$2
+
+if [[ -z "$service" || -z "$host" ]]; then
+  echo "UNKNOWN: Invalid arguments; Usage: check_webui.sh service_name host_name";
+  exit 3;
+fi
+
+case "$service" in
+
+resourcemanager) 
+    rm_weburl="http://$host:8088"
+    if [[ `checkurl "$rm_weburl"` -ne 0 ]]; then 
+      echo "WARNING: YARN ResourceManager web UI not accessible : $rm_weburl";
+      exit 1;
+    fi
+    ;;
+namenode)
+    nnweburl="http://$host:50070"
+    if [[ `checkurl "$nnweburl"` -ne 0 ]] ; then 
+      echo "WARNING: NameNode web UI not accessible : $nnweburl";
+      exit 1;
+    fi
+    ;;
+jobhistoryserver2)
+    mr_jhs_weburl="http://$host:19888/"
+    if [[ `checkurl "$mr_jhs_weburl"` -ne 0 ]]; then 
+      echo "WARNING: MapReduce JobHistoryServer web UI not accessible : $mr_jhs_weburl";
+      exit 1;
+    fi
+    ;;
+hbase)
+    hbaseweburl="http://$host:60010/master-status"
+    jhweburl="http://domU-12-31-39-16-DC-FB.compute-1.internal:51111/jobhistoryhome.jsp"
+    if [[ `checkurl "$hbaseweburl"` -ne 0 ]]; then 
+      echo "WARNING: HBase Master web UI not accessible : $hbaseweburl"; 
+      exit 1;
+    fi
+    ;;
+*) echo "UNKNOWN: Invalid service name [$service], valid options [resourcemanager|jobhistoryserver2|hbase|namenode]"
+   exit 3
+   ;;
+esac
+
+echo "OK: Successfully accessed $service Web UI"
+exit 0;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_all_hosts.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_all_hosts.rb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_all_hosts.rb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_all_hosts.rb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,35 @@
+#
+#
+# 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.
+#
+#
+module Puppet::Parser::Functions
+  newfunction(:hdp_nagios_all_hosts, :type => :rvalue) do 
+    hg_defs = function_hdp_template_var("hostgroup_defs")
+    ret = Array.new
+    if hg_defs.kind_of?(Hash)
+      hg_defs.each_value do |info|
+        h = function_hdp_host(info['host_member_info'])
+        unless function_hdp_is_empty(h)
+          ret += [h].flatten 
+        end
+      end
+    end
+    ret.uniq
+  end
+end

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_compute_target_hosts.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_compute_target_hosts.rb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_compute_target_hosts.rb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_compute_target_hosts.rb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,42 @@
+#
+#
+# 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.
+#
+#
+module Puppet::Parser::Functions
+  newfunction(:hdp_nagios_compute_target_hosts, :type => :rvalue) do |args|
+    args = function_hdp_args_as_array(args)
+    monitored_hosts = args[0]
+    component_name_mapping = args[1]
+    ret = Hash.new
+    monitored_hosts.each do |host_info|
+      hostname = host_info.keys.first
+      cmps = host_info.values.first
+      cmps.each do |cmp|
+        next unless host_var_info = component_name_mapping[cmp]
+        host_var = host_var_info['host_var']
+	if host_var_info['type'] == 'array'
+          (ret[host_var] ||= Array.new) << hostname
+	elsif host_var_info['type'] == 'scalar'
+	  ret[host_var] = hostname
+        end
+      end
+    end	
+    ret
+  end
+end

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_members_exist.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_members_exist.rb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_members_exist.rb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_members_exist.rb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,34 @@
+#
+#
+# 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.
+#
+#
+module Puppet::Parser::Functions
+  newfunction(:hdp_nagios_members_exist, :type => :rvalue) do |args|
+    args = function_hdp_args_as_array(args)
+    host_type = args[0]
+    hg_defs = function_hdp_template_var("hostgroup_defs")
+    if  hg_defs.kind_of?(Hash)
+      #TODO: see if needed    Puppet::Parser::Functions.autoloader.loadall
+      member_info = (hg_defs[host_type]||{})['host_member_info']
+      member_info and not function_hdp_is_empty(function_hdp_host(member_info))
+    else
+      nil
+    end
+  end
+end

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_target_hosts.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_target_hosts.rb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_target_hosts.rb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/lib/puppet/parser/functions/hdp_nagios_target_hosts.rb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,28 @@
+#
+#
+# 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.
+#
+#
+module Puppet::Parser::Functions
+  newfunction(:hdp_nagios_target_hosts, :type => :rvalue) do |args|
+    args = function_hdp_args_as_array(args)
+    host_types = args[0]
+#TODO: see if needed       Puppet::Parser::Functions.autoloader.loadall
+    host_types.map{|t|function_hdp_host(t)}.map{|h|function_hdp_is_empty(h) ? [] : [h].flatten}.flatten
+  end
+end

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/init.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/init.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/init.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios(){}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/nagios/service_check.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/nagios/service_check.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/nagios/service_check.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/nagios/service_check.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,36 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::nagios::service_check() 
+{
+  
+  anchor { 'hdp2-nagios::nagios::service_check::begin':}
+
+  exec { 'nagios':
+    command   => "/etc/init.d/nagios status | grep 'is running'",
+    tries     => 3,
+    try_sleep => 5,
+    path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+    before      => Anchor['hdp2-nagios::nagios::service_check::end'],
+    logoutput => "true"
+  }
+
+  anchor{ 'hdp2-nagios::nagios::service_check::end':}
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/params.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/params.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/params.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,59 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::params() inherits hdp2::params
+{   
+ 
+  $nagios_user = "nagios"
+  $nagios_group = "nagios"
+  
+  $conf_dir = hdp_default("nagios_conf_dir","/etc/nagios")
+
+  $plugins_dir = "/usr/lib64/nagios/plugins"
+
+  $nagios_obj_dir = hdp_default("nagios_obj_dir","/etc/nagios/objects")
+  $nagios_host_cfg = hdp_default("nagios_host_cfg","${nagios_obj_dir}/hadoop-hosts.cfg")
+  $nagios_hostgroup_cfg = hdp_default("nagios_hostgroup_cfg","${nagios_obj_dir}/hadoop-hostgroups.cfg")
+  $nagios_servicegroup_cfg = hdp_default("nagios_servicegroup_cfg","${nagios_obj_dir}/hadoop-servicegroups.cfg")
+  $nagios_service_cfg = hdp_default("nagios_service_cfg","${nagios_obj_dir}/hadoop-services.cfg")
+  $nagios_command_cfg = hdp_default("nagios_command_cfg","${nagios_obj_dir}/hadoop-commands.cfg")
+  
+  $nagios_web_login = hdp_default("nagios_web_login","nagiosadmin")
+  $nagios_web_password = hdp_default("nagios_web_password","admin")
+  
+  $dfs_data_dir = $hdp2::params::dfs_data_dir
+   
+  $nagios_contact = hdp_default("nagios/nagios-contacts/nagios_contact","monitor\@monitor.com")
+
+  $hostgroup_defs = {
+    namenode => {host_member_info => 'namenode_host'},
+    snamenode => {host_member_info => 'snamenode_host'},
+    slaves => {host_member_info => 'slave_hosts'},
+    nagios-server => {host_member_info => 'nagios_server_host'},
+    resourcemanager => {host_member_info => 'yarn_rm_host'},
+    ganglia-server => {host_member_info => 'ganglia_server_host'},
+    zookeeper-servers => {host_member_info => 'zookeeper_hosts'},
+    hbasemaster => {host_member_info => 'hbase_master_host'},
+    hiveserver => {host_member_info => 'hive_server_host'},
+    region-servers => {host_member_info => 'hbase_rs_hosts'},
+    oozie-server => {host_member_info => 'oozie_server'},
+    templeton-server => {host_member_info => 'templeton_server_host'}
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,114 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::server(
+  $service_state = $hdp2::params::cluster_service_state
+) inherits hdp2-nagios::params
+{
+
+  $nagios_config_dir = $hdp2-nagios::params::conf_dir
+  $plugins_dir = $hdp2-nagios::params::plugins_dir
+  $nagios_obj_dir = $hdp2-nagios::params::nagios_obj_dir
+
+  if ($service_state == 'no_op') {
+  } elsif ($service_state in ['uninstalled']) {
+    class { 'hdp2-nagios::server::packages' : 
+      service_state => uninstalled
+    }
+
+    hdp2::exec { "rm -f /var/nagios/rw/nagios.cmd" :
+      command => "rm -f /var/nagios/rw/nagios.cmd",
+      unless => "test ! -e  /var/nagios/rw/nagios.cmd"
+    }
+
+    hdp2::exec { "rm -rf /tmp/hadoop-nagios" :
+      command => "rm -rf /tmp/hadoop-nagios",
+      unless => "test ! -e  /tmp/hadoop-nagios"
+    }
+
+    hdp2::directory { $nagios_config_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+    hdp2::directory { $plugins_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+    hdp2::directory { $nagios_obj_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+     Class['hdp2-nagios::server::packages'] -> Exec['rm -f /var/nagios/rw/nagios.cmd'] -> Exec['rm -rf /tmp/hadoop-nagios'] -> Hdp2::Directory[$nagios_config_dir] -> Hdp2::Directory[$plugins_dir] -> Hdp2::Directory[$nagios_obj_dir]
+
+  } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+    class { 'hdp2-nagios::server::packages' : }
+
+    hdp2::directory { $nagios_config_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+    hdp2::directory { $plugins_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+    hdp2::directory { $nagios_obj_dir:
+      service_state => $service_state,
+      force => true
+    }
+
+
+    class { 'hdp2-nagios::server::config': 
+      notify => Class['hdp2-nagios::server::services']
+    }
+
+    class { 'hdp2-nagios::server::web_permisssions': }
+
+    class { 'hdp2-nagios::server::services': ensure => $service_state}
+
+    Class['hdp2-nagios::server::packages'] -> Hdp2::Directory[$nagios_config_dir] -> Hdp2::Directory[$plugins_dir] -> Hdp2::Directory[$nagios_obj_dir] -> Class['hdp2-nagios::server::config'] -> 
+    Class['hdp2-nagios::server::web_permisssions'] -> Class['hdp2-nagios::server::services']
+  } else {
+    hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+  }
+}
+
+class hdp2-nagios::server::web_permisssions()
+{
+  $web_login = $hdp2-nagios::params::nagios_web_login
+  $cmd = "htpasswd -c -b  /etc/nagios/htpasswd.users ${web_login} ${hdp2-nagios::params::nagios_web_password}"
+  $test = "grep ${web_user} /etc/nagios/htpasswd.users"
+  hdp2::exec { $cmd :
+    command => $cmd,
+    unless => $test
+  }
+}
+
+class hdp2-nagios::server::services($ensure)
+{
+  if ($ensure in ['running','stopped']) {
+    service { 'nagios': ensure => $ensure}
+    anchor{'hdp2-nagios::server::services::begin':} ->  Service['nagios'] ->  anchor{'hdp2-nagios::server::services::end':}
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/config.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/config.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/config.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/config.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,75 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::server::config()
+{
+
+  $host_cfg = $hdp2-nagios::params::nagios_host_cfg
+  
+  hdp2-nagios::server::configfile { 'nagios.cfg': conf_dir => $hdp2-nagios::params::conf_dir }
+  hdp2-nagios::server::configfile { 'hadoop-hosts.cfg': }
+  hdp2-nagios::server::configfile { 'hadoop-hostgroups.cfg': }
+  hdp2-nagios::server::configfile { 'hadoop-servicegroups.cfg': }
+  hdp2-nagios::server::configfile { 'hadoop-services.cfg': }
+  hdp2-nagios::server::configfile { 'hadoop-commands.cfg': }
+  hdp2-nagios::server::configfile { 'contacts.cfg': }
+
+  hdp2-nagios::server::check { 'check_cpu.pl': }
+  hdp2-nagios::server::check { 'check_datanode_storage.php': }
+  hdp2-nagios::server::check { 'check_aggregate.php': }
+  hdp2-nagios::server::check { 'check_hdfs_blocks.php': }
+  hdp2-nagios::server::check { 'check_hdfs_capacity.php': }
+  hdp2-nagios::server::check { 'check_rpcq_latency.php': }
+  hdp2-nagios::server::check { 'check_webui.sh': }
+  hdp2-nagios::server::check { 'check_name_dir_status.php': }
+  hdp2-nagios::server::check { 'check_puppet_agent_status.php': }
+  hdp2-nagios::server::check { 'check_oozie_status.sh': }
+  hdp2-nagios::server::check { 'check_templeton_status.sh': }
+  hdp2-nagios::server::check { 'check_hive_metastore_status.sh': }
+
+  anchor{'hdp2-nagios::server::config::begin':} -> Hdp2-nagios::Server::Configfile<||> -> anchor{'hdp2-nagios::server::config::end':}
+  Anchor['hdp2-nagios::server::config::begin'] -> Hdp2-nagios::Server::Check<||> -> Anchor['hdp2-nagios::server::config::end']
+}
+
+
+###config file helper
+define hdp2-nagios::server::configfile(
+  $owner = $hdp2-nagios::params::nagios_user,
+  $conf_dir = $hdp2-nagios::params::nagios_obj_dir,
+  $mode = undef
+) 
+{
+  
+  hdp2::configfile { "${conf_dir}/${name}":
+    component      => 'nagios',
+    owner          => $owner,
+    mode           => $mode
+  }
+
+  
+}
+
+define hdp2-nagios::server::check()
+{
+  file { "${hdp2-nagios::params::plugins_dir}/${name}":
+    source => "puppet:///modules/hdp2-nagios/${name}", 
+    mode => '0755'
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/packages.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/packages.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/packages.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/server/packages.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,61 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::server::packages(
+  $service_state = $hdp2::params::cluster_service_state
+)
+{
+  if ($service_state == 'no_op') {
+  } elsif ($service_state in ['uninstalled']) {
+      hdp2-nagios::server::package { ['nagios-server','nagios-fping','nagios-plugins','nagios-addons']:
+      ensure => 'uninstalled'
+    }
+  } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+    case $hdp2::params::hdp_os_type {
+      centos6, rhel6: {
+        hdp2-nagios::server::package { ['nagios-server','nagios-fping','nagios-plugins','nagios-addons']:
+          ensure => 'present'
+        }
+      }
+      default: {
+        hdp2-nagios::server::package { ['nagios-server','nagios-fping','nagios-plugins','nagios-addons','nagios-php-pecl-json']:
+          ensure => 'present'
+        }
+      }
+    }
+  }
+
+  Hdp2-nagios::Server::Package['nagios-plugins'] -> Hdp2::Package['nagios-addons'] #other order produces package conflict
+
+  anchor{'hdp2-nagios::server::packages::begin':} -> Hdp2-nagios::Server::Package<||> -> anchor{'hdp2-nagios::server::packages::end':}
+  Anchor['hdp2-nagios::server::packages::begin'] -> Hdp2::Package['nagios-addons'] -> Anchor['hdp2-nagios::server::packages::end']
+  Hdp2-nagios::Server::Package['nagios-fping'] -> Hdp2-nagios::Server::Package['nagios-plugins']
+}
+
+
+define hdp2-nagios::server::package(
+  $ensure = present
+)
+{
+  hdp2::package { $name: 
+    ensure      => $ensure,
+    java_needed => false
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/target.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/target.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/target.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/manifests/target.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+class hdp2-nagios::target(){}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/contacts.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/contacts.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/contacts.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/contacts.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,76 @@
+###############################################################################
+# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
+#
+# Last Modified: 05-31-2007
+#
+# NOTES: This config file provides you with some example contact and contact
+#        group definitions that you can reference in host and service
+#        definitions.
+#       
+#        You don't need to keep these definitions in a separate file from your
+#        other object definitions.  This has been done just to make things
+#        easier to understand.
+#
+###############################################################################
+
+#
+#
+# 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.
+#
+#
+#
+
+
+###############################################################################
+###############################################################################
+#
+# CONTACTS
+#
+###############################################################################
+###############################################################################
+
+# Just one contact defined by default - the Nagios admin (that's you)
+# This contact definition inherits a lot of default values from the 'generic-contact' 
+# template which is defined elsewhere.
+
+define contact{
+        contact_name                    <%=scope.function_hdp_template_var("nagios_web_login")%>		; Short name of user
+	use				generic-contact		; Inherit default values from generic-contact template (defined above)
+        alias                           Nagios Admin		; Full name of user
+
+        email                           <%=scope.function_hdp_template_var("nagios_contact")%>	; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
+        }
+
+
+
+###############################################################################
+###############################################################################
+#
+# CONTACT GROUPS
+#
+###############################################################################
+###############################################################################
+
+# We only have one contact in this simple configuration file, so there is
+# no need to create more than one contact group.
+
+define contactgroup {
+        contactgroup_name       admins
+        alias                   Nagios Administrators
+        members                 <%=scope.function_hdp_template_var("nagios_web_login")%>
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-commands.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-commands.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-commands.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-commands.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,88 @@
+#
+#
+# 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.
+#
+#
+#
+
+# 'check_cpu' check remote cpu load
+define command {
+        command_name    check_cpu
+        command_line    $USER1$/check_cpu.pl -H $HOSTADDRESS$ -C hadoop -w $ARG1$ -c $ARG2$
+       }
+
+# Check data node storage full 
+define command {
+        command_name    check_datanode_storage
+        command_line    php $USER1$/check_datanode_storage.php -h $HOSTADDRESS$ -p $ARG1$ -w $ARG2$ -c $ARG3$
+       }
+
+define command{
+        command_name    check_hdfs_blocks
+        command_line    php $USER1$/check_hdfs_blocks.php -h $HOSTADDRESS$ -p $ARG1$ -w $ARG2$ -c $ARG3$
+       }
+
+define command{
+        command_name    check_hdfs_capacity
+        command_line    php $USER1$/check_hdfs_capacity.php -h $HOSTADDRESS$ -p $ARG1$ -w $ARG2$ -c $ARG3$
+       }
+
+define command{
+        command_name    check_aggregate
+        command_line    php $USER1$/check_aggregate.php -f /var/nagios/status.dat -s 1 -t service -n $ARG1$ -w $ARG2$ -c $ARG3$
+       }
+
+define command{
+        command_name    check_rpcq_latency
+        command_line    php $USER1$/check_rpcq_latency.php -h $HOSTADDRESS$ -p $ARG2$ -n $ARG1$ -w $ARG3$ -c $ARG4$
+       }
+
+define command{
+        command_name    check_nagios
+        command_line    $USER1$/check_nagios -e $ARG1$ -F $ARG2$ -C $ARG3$ 
+       }
+
+define command{
+        command_name    check_webui
+        command_line    $USER1$/check_webui.sh $ARG1$ $HOSTADDRESS$
+       }
+
+define command{
+        command_name    check_name_dir_status
+        command_line    php $USER1$/check_name_dir_status.php -h $HOSTADDRESS$ -p $ARG1$
+       }
+
+define command{
+        command_name    check_puppet_agent_status
+        command_line    php $USER1$/check_puppet_agent_status.php -h $HOSTADDRESS$
+       }
+  
+define command{
+        command_name    check_oozie_status
+        command_line    $USER1$/check_oozie_status.sh $HOSTADDRESS$ $ARG1$ $ARG2$
+       }
+
+define command{
+        command_name    check_templeton_status
+        command_line    $USER1$/check_templeton_status.sh $HOSTADDRESS$ $ARG1$ $ARG2$ 
+       }
+
+define command{
+        command_name    check_hive_metastore_status
+        command_line    $USER1$/check_hive_metastore_status.sh $HOSTADDRESS$ $ARG1$
+       }

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hostgroups.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hostgroups.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hostgroups.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hostgroups.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,20 @@
+<% all_hosts = Array.new -%>
+<%scope.function_hdp_template_var("hostgroup_defs").each do |name,info|-%>
+<%members = scope.function_hdp_host(info['host_member_info'])-%>
+<%unless scope.function_hdp_is_empty(members) -%>
+<% all_hosts += [members].flatten-%>
+define hostgroup {
+        hostgroup_name  <%=name%>
+        alias           <%=name%>
+        members         <%=[members].flatten.join(',')%>
+}
+
+<%end-%>
+<%end%>
+<%unless all_hosts.empty?-%>
+define hostgroup {
+        hostgroup_name  all-servers
+        alias           All Servers
+        members         <%=all_hosts.uniq.join(',')%>
+}
+<%end%>
\ No newline at end of file

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hosts.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hosts.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hosts.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-hosts.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,16 @@
+<%scope.function_hdp_nagios_all_hosts().each do |host|-%>
+define host {
+        alias        <%=host%>
+        host_name    <%=host%>
+        use          linux-server
+        address      <%=host%>
+        check_interval         0.25
+        retry_interval         0.25
+        max_check_attempts     4
+        notifications_enabled     1
+        first_notification_delay  0     # Send notification soon after change in the hard state
+        notification_interval     0     # Send the notification once
+        notification_options      d,u,r
+}
+
+<%end%>

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-servicegroups.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-servicegroups.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-servicegroups.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-servicegroups.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,44 @@
+define servicegroup {
+  servicegroup_name  HDFS
+  alias  HDFS Checks
+}
+define servicegroup {
+  servicegroup_name YARN 
+  alias  YARN Checks
+}
+define servicegroup {
+  servicegroup_name  MAPREDUCE
+  alias  MAPREDUCE Checks
+}
+define servicegroup {
+  servicegroup_name  HBASE
+  alias  HBASE Checks
+}
+define servicegroup {
+  servicegroup_name  OOZIE
+  alias  OOZIE Checks
+}
+define servicegroup {
+  servicegroup_name  TEMPLETON
+  alias  TEMPLETON Checks
+}
+define servicegroup {
+  servicegroup_name  NAGIOS
+  alias  NAGIOS Checks
+}
+define servicegroup {
+  servicegroup_name  GANGLIA
+  alias  GANGLIA Checks
+}
+define servicegroup {
+  servicegroup_name  HIVE-METASTORE
+  alias  HIVE-METASTORE Checks
+}
+define servicegroup {
+  servicegroup_name  ZOOKEEPER
+  alias  ZOOKEEPER Checks
+}
+define servicegroup {
+  servicegroup_name  PUPPET
+  alias  Puppet Agent Checks
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-services.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-services.cfg.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-services.cfg.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-nagios/templates/hadoop-services.cfg.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,467 @@
+#
+#
+# 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.
+#
+#
+
+
+# NAGIOS SERVER Check (status log update)
+<%if scope.function_hdp_nagios_members_exist('nagios-server')-%>
+define service {
+        name                            hadoop-service
+        use                             generic-service
+        notification_options            w,u,c
+        first_notification_delay        0
+        notification_interval           0     # Send the notification once
+}
+
+define service {        
+        hostgroup_name          all-servers
+        use                     hadoop-service
+        service_description     PUPPET::Puppet agent down
+        servicegroups           PUPPET
+        check_command           check_tcp!8139!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+define service {        
+        hostgroup_name          nagios-server        
+        use                     hadoop-service
+        service_description     NAGIOS::Nagios status log staleness
+        servicegroups           NAGIOS
+        check_command           check_nagios!10!/var/nagios/status.dat!/usr/bin/nagios
+        normal_check_interval   5
+        retry_check_interval    0.5
+        max_check_attempts      2
+}
+
+# NAGIOS SERVER HDFS Checks
+define service {
+        hostgroup_name          nagios-server
+        use                     hadoop-service
+        service_description     HDFS::Percent DataNodes storage full
+        servicegroups           HDFS
+        check_command           check_aggregate!"DATANODE::Storage full"!10%!30%
+        normal_check_interval   2
+        retry_check_interval    1 
+        max_check_attempts      1
+}
+
+define service {
+        hostgroup_name          nagios-server
+        use                     hadoop-service
+        service_description     HDFS::Percent DataNodes down
+        servicegroups           HDFS
+        check_command           check_aggregate!"DATANODE::Process down"!10%!30%
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+
+# NAGIOS SERVER YARN Checks
+define service {
+        hostgroup_name          nagios-server
+        use                     hadoop-service
+        service_description     YARN::Percent NodeManagers down
+        servicegroups           YARN
+        check_command           check_aggregate!"NODEMANAGER::Process down"!10%!30%
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+
+# NAGIOS SERVER ZOOKEEPER Checks
+<%if scope.function_hdp_nagios_members_exist('zookeeper-servers')-%>
+define service {
+        hostgroup_name          nagios-server
+        use                     hadoop-service
+        service_description     ZOOKEEPER::Percent zookeeper servers down
+        servicegroups           ZOOKEEPER
+        check_command           check_aggregate!"ZKSERVERS::ZKSERVERS Process down"!35%!70%
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+<%end-%>
+
+# NAGIOS SERVER HBASE Checks
+<%if scope.function_hdp_nagios_members_exist('hbasemaster')-%>
+define service {
+        hostgroup_name          nagios-server
+        use                     hadoop-service
+        service_description     HBASE::Percent region servers down
+        servicegroups           HBASE
+        check_command           check_aggregate!"REGIONSERVER::Process down"!10%!30%
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+<%end-%>
+<%end-%>
+
+# GANGLIA SERVER Checks
+<%if scope.function_hdp_nagios_members_exist('ganglia-server')-%>
+define service {
+        hostgroup_name          ganglia-server
+        use                     hadoop-service
+        service_description     GANGLIA::Ganglia [gmetad] Process down
+        servicegroups           GANGLIA
+        check_command           check_tcp!8651!-w 1 -c 1
+        normal_check_interval   0.25
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+define service {
+        hostgroup_name          ganglia-server
+        use                     hadoop-service
+        service_description     GANGLIA::Ganglia collector [gmond] Process down alert for slaves
+        servicegroups           GANGLIA
+        check_command           check_tcp!8660!-w 1 -c 1
+        normal_check_interval   0.25
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+define service {
+        hostgroup_name          ganglia-server
+        use                     hadoop-service
+        service_description     GANGLIA::Ganglia collector [gmond] Process down alert for namenode
+        servicegroups           GANGLIA
+        check_command           check_tcp!8661!-w 1 -c 1
+        normal_check_interval   0.25
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+define service {
+        hostgroup_name          ganglia-server
+        use                     hadoop-service
+        service_description     GANGLIA::Ganglia collector [gmond] Process down alert for resourcemanager
+        servicegroups           GANGLIA
+        check_command           check_tcp!8662!-w 1 -c 1
+        normal_check_interval   0.25
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+<%if scope.function_hdp_nagios_members_exist('hbasemaster')-%>
+define service {
+        hostgroup_name          ganglia-server
+        use                     hadoop-service
+        service_description     GANGLIA::Ganglia collector [gmond] Process down alert for hbasemaster
+        servicegroups           GANGLIA
+        check_command           check_tcp!8663!-w 1 -c 1
+        normal_check_interval   0.25
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+<%end-%>
+<%end-%>
+
+<%if scope.function_hdp_nagios_members_exist('snamenode')-%>
+# Secondary namenode checks
+define service {
+        hostgroup_name          snamenode
+        use                     hadoop-service
+        service_description     NAMENODE::Secondary Namenode Process down
+        servicegroups           HDFS
+        check_command           check_tcp!50090!-w 1 -c 1
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+<%end-%>
+<%if scope.function_hdp_nagios_members_exist('namenode')-%>
+# HDFS Checks
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     NAMENODE::Namenode Web UI down
+        servicegroups           HDFS
+        check_command           check_webui!namenode
+        normal_check_interval   1
+        retry_check_interval    1
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     NAMENODE::Namenode Edit logs directory status
+        servicegroups           HDFS
+        check_command           check_name_dir_status!50070
+        normal_check_interval   0.5
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+
+define service {        
+        hostgroup_name          namenode        
+        use                     hadoop-service
+        service_description     NAMENODE::Namenode Host CPU utilization
+        servicegroups           HDFS
+        check_command           check_cpu!200%!250%
+        normal_check_interval   5
+        retry_check_interval    2 
+        max_check_attempts      5
+}
+
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     NAMENODE::Namenode Process down
+        servicegroups           HDFS
+        check_command           check_tcp!8020!-w 1 -c 1
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     HDFS::Corrupt/Missing blocks
+        servicegroups           HDFS
+        check_command           check_hdfs_blocks!50070!0%!0%
+        normal_check_interval   2
+        retry_check_interval    1 
+        max_check_attempts      1
+}
+
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     HDFS::HDFS Capacity utilization
+        servicegroups           HDFS
+        check_command           check_hdfs_capacity!50070!80%!90%
+        normal_check_interval   10
+        retry_check_interval    1 
+        max_check_attempts      1
+}
+
+define service {
+        hostgroup_name          namenode
+        use                     hadoop-service
+        service_description     HDFS::Namenode RPC Latency
+        servicegroups           HDFS
+        check_command           check_rpcq_latency!NameNode!50070!3000!5000
+        normal_check_interval   5
+        retry_check_interval    1 
+        max_check_attempts      5
+}
+<%end-%>
+
+# YARN Checks
+<%if scope.function_hdp_nagios_members_exist('resourcemanager')-%>
+define service {
+        hostgroup_name          resourcemanager
+        use                     hadoop-service
+        service_description     RESOURCEMANAGER::ResourceManager Web UI down
+        servicegroups           YARN
+        check_command           check_webui!resourcemanager
+        normal_check_interval   1
+        retry_check_interval    1
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          resourcemanager
+        use                     hadoop-service
+        service_description     RESOURCEMANAGER::JobHistoryServer Web UI down
+        servicegroups           YARN
+        check_command           check_webui!jobhistoryserver2
+        normal_check_interval   1
+        retry_check_interval    1
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          resourcemanager
+        use                     hadoop-service
+        service_description     RESOURCEMANAGER::ResourceManager CPU utilization
+        servicegroups           YARN
+        check_command           check_cpu!200%!250%
+        normal_check_interval   5
+        retry_check_interval    2 
+        max_check_attempts      5
+}
+
+define service {
+        hostgroup_name          resourcemanager
+        use                     hadoop-service
+        service_description     RESOURCEMANAGER::ResourceManager Process down
+        servicegroups           YARN
+        check_command           check_tcp!8088!-w 1 -c 1
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+
+define service {
+        hostgroup_name          resourcemanager
+        use                     hadoop-service
+        service_description     YARN::ResourceManager RPC Latency
+        servicegroups           YARN
+        check_command           check_rpcq_latency!ResourceManager!8088!3000!5000
+        normal_check_interval   5
+        retry_check_interval    1 
+        max_check_attempts      5
+}
+<%end-%>
+
+<%if scope.function_hdp_nagios_members_exist('slaves')-%>
+# HDFS::DATANODE Checks
+define service {
+        hostgroup_name          slaves
+        use                     hadoop-service
+        service_description     DATANODE::Process down
+        servicegroups           HDFS
+        check_command           check_tcp!50010!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          slaves
+        use                     hadoop-service
+        service_description     DATANODE::Storage full
+        servicegroups           HDFS
+        check_command           check_datanode_storage!50075!90%!90%
+        normal_check_interval   5
+        retry_check_interval    1
+        max_check_attempts      2
+}
+
+# YARN::NODEMANAGER Checks 
+define service {
+        hostgroup_name          slaves
+        use                     hadoop-service
+        service_description     NODEMANAGER::Process down
+        servicegroups           YARN
+        check_command           check_tcp!50060!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+<%end-%>
+
+<%if scope.function_hdp_nagios_members_exist('zookeeper-servers')-%>
+# ZOOKEEPER Checks
+define service {
+        hostgroup_name          zookeeper-servers
+        use                     hadoop-service
+        service_description     ZKSERVERS::ZKSERVERS Process down
+        servicegroups           ZOOKEEPER
+        check_command           check_tcp!2181!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+<%end-%>
+
+<%if scope.function_hdp_nagios_members_exist('hbasemaster')-%>
+# HBASE::REGIONSERVER Checks
+define service {
+        hostgroup_name          region-servers
+        use                     hadoop-service
+        service_description     REGIONSERVER::Process down
+        servicegroups           HBASE
+        check_command           check_tcp!60020!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+
+# HBASE:: MASTER Checks
+define service {
+        hostgroup_name          hbasemaster
+        use                     hadoop-service
+        service_description     HBASEMASTER::HBase Web UI down
+        servicegroups           HBASE
+        check_command           check_webui!hbase
+        normal_check_interval   1
+        retry_check_interval    1
+        max_check_attempts      3
+}
+
+define service {
+        hostgroup_name          hbasemaster
+        use                     hadoop-service
+        service_description     HBASEMASTER::HBaseMaster CPU utilization
+        servicegroups           HBASE
+        check_command           check_cpu!200%!250%
+        normal_check_interval   5
+        retry_check_interval    2 
+        max_check_attempts      5
+}
+
+define service {
+        hostgroup_name          hbasemaster
+        use                     hadoop-service
+        service_description     HBASEMASTER::HBaseMaster Process down
+        servicegroups           HBASE
+        check_command           check_tcp!60000!-w 1 -c 1
+        normal_check_interval   0.5
+        retry_check_interval    0.25
+        max_check_attempts      4
+}
+<%end-%>
+
+<%if scope.function_hdp_nagios_members_exist('hiveserver')-%>
+# HIVE Metastore check
+define service {
+        hostgroup_name          hiveserver
+        use                     hadoop-service
+        service_description     HIVE-METASTORE::HIVE-METASTORE status check
+        servicegroups           HIVE-METASTORE
+        check_command           check_hive_metastore_status!9083
+        normal_check_interval   0.5
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+<%end-%>
+<%if scope.function_hdp_nagios_members_exist('oozie-server')-%>
+# Oozie check
+define service {
+        hostgroup_name          oozie-server
+        use                     hadoop-service
+        service_description     OOZIE::Oozie status check
+        servicegroups           OOZIE
+        check_command           check_oozie_status!11000!<%=scope.function_hdp_template_var("java32_home") %>
+        normal_check_interval   1
+        retry_check_interval    1
+        max_check_attempts      3
+}
+<%end-%>
+<%if scope.function_hdp_nagios_members_exist('templeton-server')-%>
+# Templeton check
+define service {
+        hostgroup_name          templeton-server
+        use                     hadoop-service
+        service_description     TEMPLETON::Templeton status check
+        servicegroups           TEMPLETON
+        check_command           check_templeton_status!50111!v1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+<%end-%>