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 [3/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-ganglia/files/gmetad.init
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetad.init?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetad.init (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetad.init Mon Oct 15 05:55:46 2012
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+# Remember to keep this in-sync with the definition of 
+# GANGLIA_RUNTIME_COMPONENTS_UNPACK_DIR in monrpmInstaller.sh.
+HDP_GANGLIA_RUNTIME_COMPONENTS_DIR=/usr/libexec/hdp/ganglia
+HDP_GANLIA_GMETAD_STARTER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/startGmetad.sh
+HDP_GANLIA_GMETAD_STOPPER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/stopGmetad.sh
+HDP_GANLIA_GMETAD_CHECKER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/checkGmetad.sh
+
+RETVAL=0
+
+case "$1" in
+   start)
+      echo "============================="
+      echo "Starting hdp-gmetad..."
+      echo "============================="
+      [ -f ${HDP_GANLIA_GMETAD_STARTER} ] || exit 1
+      eval "${HDP_GANLIA_GMETAD_STARTER}"
+      RETVAL=$?
+      echo
+      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hdp-gmetad
+      ;;
+
+  stop)
+      echo "=================================="
+      echo "Shutting down hdp-gmetad..."
+      echo "=================================="
+      [ -f ${HDP_GANLIA_GMETAD_STOPPER} ] || exit 1
+      eval "${HDP_GANLIA_GMETAD_STOPPER}"
+      RETVAL=$?
+      echo
+      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hdp-gmetad
+      ;;
+
+  restart|reload)
+   	$0 stop
+   	$0 start
+   	RETVAL=$?
+	;;
+  status)
+      echo "======================================="
+      echo "Checking status of hdp-gmetad..."
+      echo "======================================="
+      [ -f ${HDP_GANLIA_GMETAD_CHECKER} ] || exit 1
+      eval "${HDP_GANLIA_GMETAD_CHECKER}"
+      RETVAL=$?
+      ;;
+  *)
+	echo "Usage: $0 {start|stop|restart|status}"
+	exit 1
+esac
+
+exit $RETVAL

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetadLib.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetadLib.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetadLib.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmetadLib.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,196 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Slurp in all our user-customizable settings.
+source ./gangliaEnv.sh;
+
+# Get access to Ganglia-wide constants etc.
+source ./gangliaLib.sh;
+
+GMETAD_BIN=/usr/sbin/gmetad;
+GMETAD_CONF_FILE=${GANGLIA_CONF_DIR}/gmetad.conf;
+GMETAD_PID_FILE=${GANGLIA_RUNTIME_DIR}/gmetad.pid;
+
+function getGmetadLoggedPid()
+{
+    if [ -e "${GMETAD_PID_FILE}" ]
+    then
+        echo `cat ${GMETAD_PID_FILE}`;
+    fi
+}
+
+function getGmetadRunningPid()
+{
+    gmetadLoggedPid=`getGmetadLoggedPid`;
+
+    if [ -n "${gmetadLoggedPid}" ]
+    then
+        echo `ps -o pid=MYPID -p ${gmetadLoggedPid} | tail -1 | awk '{print $1}' | grep -v MYPID`;
+    fi
+}
+
+function generateGmetadConf()
+{
+    now=`date`;
+
+    cat <<END_OF_GMETAD_CONF_1
+#################### Generated by ${0} on ${now} ####################
+#
+#-------------------------------------------------------------------------------
+# Setting the debug_level to 1 will keep daemon in the forground and
+# show only error messages. Setting this value higher than 1 will make 
+# gmetad output debugging information and stay in the foreground.
+# default: 0
+# debug_level 10
+#
+#-------------------------------------------------------------------------------
+# What to monitor. The most important section of this file. 
+#
+# The data_source tag specifies either a cluster or a grid to
+# monitor. If we detect the source is a cluster, we will maintain a complete
+# set of RRD databases for it, which can be used to create historical 
+# graphs of the metrics. If the source is a grid (it comes from another gmetad),
+# we will only maintain summary RRDs for it.
+#
+# Format: 
+# data_source "my cluster" [polling interval] address1:port addreses2:port ...
+# 
+# The keyword 'data_source' must immediately be followed by a unique
+# string which identifies the source, then an optional polling interval in 
+# seconds. The source will be polled at this interval on average. 
+# If the polling interval is omitted, 15sec is asssumed. 
+#
+# If you choose to set the polling interval to something other than the default,
+# note that the web frontend determines a host as down if its TN value is less
+# than 4 * TMAX (20sec by default).  Therefore, if you set the polling interval
+# to something around or greater than 80sec, this will cause the frontend to
+# incorrectly display hosts as down even though they are not.
+#
+# A list of machines which service the data source follows, in the 
+# format ip:port, or name:port. If a port is not specified then 8649
+# (the default gmond port) is assumed.
+# default: There is no default value
+#
+# data_source "my cluster" 10 localhost  my.machine.edu:8649  1.2.3.5:8655
+# data_source "my grid" 50 1.3.4.7:8655 grid.org:8651 grid-backup.org:8651
+# data_source "another source" 1.3.4.7:8655  1.3.4.8
+END_OF_GMETAD_CONF_1
+
+    # Get info about all the configured Ganglia clusters.
+    getGangliaClusterInfo | while read gangliaClusterInfoLine
+    do
+        # From each, parse out ${gmondClusterName}, ${gmondMasterIP} and ${gmondPort}... 
+        read gmondClusterName gmondMasterIP gmondPort <<<`echo ${gangliaClusterInfoLine}`;
+        # ...and generate a corresponding data_source line for gmetad.conf. 
+        echo "data_source \"${gmondClusterName}\" ${gmondMasterIP}:${gmondPort}";
+    done
+
+    cat <<END_OF_GMETAD_CONF_2
+#
+# Round-Robin Archives
+# You can specify custom Round-Robin archives here (defaults are listed below)
+#
+# RRAs "RRA:AVERAGE:0.5:1:244" "RRA:AVERAGE:0.5:24:244" "RRA:AVERAGE:0.5:168:244" "RRA:AVERAGE:0.5:672:244" \
+#      "RRA:AVERAGE:0.5:5760:374"
+#
+#-------------------------------------------------------------------------------
+# Scalability mode. If on, we summarize over downstream grids, and respect
+# authority tags. If off, we take on 2.5.0-era behavior: we do not wrap our output
+# in <GRID></GRID> tags, we ignore all <GRID> tags we see, and always assume
+# we are the "authority" on data source feeds. This approach does not scale to
+# large groups of clusters, but is provided for backwards compatibility.
+# default: on
+# scalable off
+#
+#-------------------------------------------------------------------------------
+# The name of this Grid. All the data sources above will be wrapped in a GRID
+# tag with this name.
+# default: unspecified
+gridname "HDP_GRID"
+#
+#-------------------------------------------------------------------------------
+# The authority URL for this grid. Used by other gmetads to locate graphs
+# for our data sources. Generally points to a ganglia/
+# website on this machine.
+# default: "http://hostname/ganglia/",
+#   where hostname is the name of this machine, as defined by gethostname().
+# authority "http://mycluster.org/newprefix/"
+#
+#-------------------------------------------------------------------------------
+# List of machines this gmetad will share XML with. Localhost
+# is always trusted. 
+# default: There is no default value
+# trusted_hosts 127.0.0.1 169.229.50.165 my.gmetad.org
+#
+#-------------------------------------------------------------------------------
+# If you want any host which connects to the gmetad XML to receive
+# data, then set this value to "on"
+# default: off
+# all_trusted on
+#
+#-------------------------------------------------------------------------------
+# If you don't want gmetad to setuid then set this to off
+# default: on
+# setuid off
+#
+#-------------------------------------------------------------------------------
+# User gmetad will setuid to (defaults to "nobody")
+# default: "nobody"
+setuid_username "${GMETAD_USER}"
+#
+#-------------------------------------------------------------------------------
+# Umask to apply to created rrd files and grid directory structure
+# default: 0 (files are public)
+# umask 022
+#
+#-------------------------------------------------------------------------------
+# The port gmetad will answer requests for XML
+# default: 8651
+# xml_port 8651
+#
+#-------------------------------------------------------------------------------
+# The port gmetad will answer queries for XML. This facility allows
+# simple subtree and summation views of the XML tree.
+# default: 8652
+# interactive_port 8652
+#
+#-------------------------------------------------------------------------------
+# The number of threads answering XML requests
+# default: 4
+# server_threads 10
+#
+#-------------------------------------------------------------------------------
+# Where gmetad stores its round-robin databases
+# default: "/var/lib/ganglia/rrds"
+# rrd_rootdir "/some/other/place"
+#
+#-------------------------------------------------------------------------------
+# In earlier versions of gmetad, hostnames were handled in a case
+# sensitive manner
+# If your hostname directories have been renamed to lower case,
+# set this option to 0 to disable backward compatibility.
+# From version 3.2, backwards compatibility will be disabled by default.
+# default: 1   (for gmetad < 3.2)
+# default: 0   (for gmetad >= 3.2)
+case_sensitive_hostnames 1
+END_OF_GMETAD_CONF_2
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmond.init
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmond.init?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmond.init (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmond.init Mon Oct 15 05:55:46 2012
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+# Remember to keep this in-sync with the definition of 
+# GANGLIA_RUNTIME_COMPONENTS_UNPACK_DIR in monrpmInstaller.sh.
+HDP_GANGLIA_RUNTIME_COMPONENTS_DIR=/usr/libexec/hdp/ganglia
+HDP_GANLIA_GMOND_STARTER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/startGmond.sh
+HDP_GANLIA_GMOND_STOPPER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/stopGmond.sh
+HDP_GANLIA_GMOND_CHECKER=${HDP_GANGLIA_RUNTIME_COMPONENTS_DIR}/checkGmond.sh
+
+RETVAL=0
+
+case "$1" in
+   start)
+      echo "============================="
+      echo "Starting hdp-gmond..."
+      echo "============================="
+      [ -f ${HDP_GANLIA_GMOND_STARTER} ] || exit 1
+      eval "${HDP_GANLIA_GMOND_STARTER}"
+      RETVAL=$?
+      echo
+      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hdp-gmond
+      ;;
+
+  stop)
+      echo "=================================="
+      echo "Shutting down hdp-gmond..."
+      echo "=================================="
+      [ -f ${HDP_GANLIA_GMOND_STOPPER} ] || exit 1
+      eval "${HDP_GANLIA_GMOND_STOPPER}"
+      RETVAL=$?
+      echo
+      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hdp-gmond
+      ;;
+
+  restart|reload)
+   	$0 stop
+   	$0 start
+   	RETVAL=$?
+	;;
+  status)
+      echo "======================================="
+      echo "Checking status of hdp-gmond..."
+      echo "======================================="
+      [ -f ${HDP_GANLIA_GMOND_CHECKER} ] || exit 1
+      eval "${HDP_GANLIA_GMOND_CHECKER}"
+      RETVAL=$?
+      ;;
+  *)
+	echo "Usage: $0 {start|stop|restart|status}"
+	exit 1
+esac
+
+exit $RETVAL

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmondLib.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmondLib.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmondLib.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/gmondLib.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,536 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Slurp in all our user-customizable settings.
+source ./gangliaEnv.sh;
+
+# Get access to Ganglia-wide constants etc.
+source ./gangliaLib.sh;
+
+GMOND_BIN=/usr/sbin/gmond;
+GMOND_CORE_CONF_FILE=gmond.core.conf;
+GMOND_MASTER_CONF_FILE=gmond.master.conf;
+GMOND_SLAVE_CONF_FILE=gmond.slave.conf;
+GMOND_PID_FILE=gmond.pid;
+
+# Functions.
+function getGmondCoreConfFileName()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        # ${clusterName} is not empty. 
+        echo "${GANGLIA_CONF_DIR}/${clusterName}/${GMOND_CORE_CONF_FILE}";
+    else
+        echo "${GANGLIA_CONF_DIR}/${GMOND_CORE_CONF_FILE}";
+    fi
+}
+
+function getGmondMasterConfFileName()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        # ${clusterName} is not empty. 
+        echo "${GANGLIA_CONF_DIR}/${clusterName}/conf.d/${GMOND_MASTER_CONF_FILE}";
+    else
+        echo "${GANGLIA_CONF_DIR}/conf.d/${GMOND_MASTER_CONF_FILE}";
+    fi
+}
+
+function getGmondSlaveConfFileName()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        # ${clusterName} is not empty. 
+        echo "${GANGLIA_CONF_DIR}/${clusterName}/conf.d/${GMOND_SLAVE_CONF_FILE}";
+    else
+        echo "${GANGLIA_CONF_DIR}/conf.d/${GMOND_SLAVE_CONF_FILE}";
+    fi
+}
+
+function getGmondPidFileName()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        # ${clusterName} is not empty. 
+        echo "${GANGLIA_RUNTIME_DIR}/${clusterName}/${GMOND_PID_FILE}";
+    else
+        echo "${GANGLIA_RUNTIME_DIR}/${GMOND_PID_FILE}";
+    fi
+}
+
+function getGmondLoggedPid()
+{
+    gmondPidFile=`getGmondPidFileName ${1}`;
+
+    if [ -e "${gmondPidFile}" ]
+    then
+        echo `cat ${gmondPidFile}`;
+    fi
+}
+
+function getGmondRunningPid()
+{
+    gmondLoggedPid=`getGmondLoggedPid ${1}`;
+
+    if [ -n "${gmondLoggedPid}" ]
+    then
+        echo `ps -o pid=MYPID -p ${gmondLoggedPid} | tail -1 | awk '{print $1}' | grep -v MYPID`;
+    fi
+}
+
+function generateGmondCoreConf()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
+
+        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
+        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
+        then
+            now=`date`;
+
+            cat << END_OF_GMOND_CORE_CONF
+#################### Generated by ${0} on ${now} ####################
+#
+/* This configuration is as close to 2.5.x default behavior as possible
+   The values closely match ./gmond/metric.h definitions in 2.5.x */
+globals {
+  daemonize = yes
+  setuid = yes
+  user = ${GMOND_USER}
+  debug_level = 0
+  max_udp_msg_len = 1472
+  mute = no
+  deaf = no 
+  allow_extra_data = yes
+  host_dmax = 0 /*secs */
+  host_tmax = 20 /*secs */
+  cleanup_threshold = 300 /*secs */
+  gexec = no
+  send_metadata_interval = 30 /*secs */
+}
+
+/*
+ * The cluster attributes specified will be used as part of the <CLUSTER>
+ * tag that will wrap all hosts collected by this instance.
+ */
+cluster {
+  name = "${gmondClusterName}"
+  owner = "unspecified"
+  latlong = "unspecified"
+  url = "unspecified"
+}
+
+/* The host section describes attributes of the host, like the location */
+host {
+  location = "unspecified"
+}
+
+/* You can specify as many tcp_accept_channels as you like to share
+ * an XML description of the state of the cluster.
+ *
+ * At the very least, every gmond must expose its XML state to 
+ * queriers from localhost.
+ */
+tcp_accept_channel {
+  bind = localhost
+  port = ${gmondPort}
+}
+
+/* Each metrics module that is referenced by gmond must be specified and
+   loaded. If the module has been statically linked with gmond, it does
+   not require a load path. However all dynamically loadable modules must
+   include a load path. */
+modules {
+  module {
+    name = "core_metrics"
+  }
+  module {
+    name = "cpu_module"
+    path = "modcpu.so"
+  }
+  module {
+    name = "disk_module"
+    path = "moddisk.so"
+  }
+  module {
+    name = "load_module"
+    path = "modload.so"
+  }
+  module {
+    name = "mem_module"
+    path = "modmem.so"
+  }
+  module {
+    name = "net_module"
+    path = "modnet.so"
+  }
+  module {
+    name = "proc_module"
+    path = "modproc.so"
+  }
+  module {
+    name = "sys_module"
+    path = "modsys.so"
+  }
+}
+
+/* The old internal 2.5.x metric array has been replaced by the following
+   collection_group directives.  What follows is the default behavior for
+   collecting and sending metrics that is as close to 2.5.x behavior as
+   possible. */
+
+/* This collection group will cause a heartbeat (or beacon) to be sent every
+   20 seconds.  In the heartbeat is the GMOND_STARTED data which expresses
+   the age of the running gmond. */
+collection_group {
+  collect_once = yes
+  time_threshold = 20
+  metric {
+    name = "heartbeat"
+  }
+}
+
+/* This collection group will send general info about this host every
+   1200 secs.
+   This information doesn't change between reboots and is only collected
+   once. */
+collection_group {
+  collect_once = yes
+  time_threshold = 1200
+  metric {
+    name = "cpu_num"
+    title = "CPU Count"
+  }
+  metric {
+    name = "cpu_speed"
+    title = "CPU Speed"
+  }
+  metric {
+    name = "mem_total"
+    title = "Memory Total"
+  }
+  /* Should this be here? Swap can be added/removed between reboots. */
+  metric {
+    name = "swap_total"
+    title = "Swap Space Total"
+  }
+  metric {
+    name = "boottime"
+    title = "Last Boot Time"
+  }
+  metric {
+    name = "machine_type"
+    title = "Machine Type"
+  }
+  metric {
+    name = "os_name"
+    title = "Operating System"
+  }
+  metric {
+    name = "os_release"
+    title = "Operating System Release"
+  }
+  metric {
+    name = "location"
+    title = "Location"
+  }
+}
+
+/* This collection group will send the status of gexecd for this host
+   every 300 secs.*/
+/* Unlike 2.5.x the default behavior is to report gexecd OFF. */
+collection_group {
+  collect_once = yes
+  time_threshold = 300
+  metric {
+    name = "gexec"
+    title = "Gexec Status"
+  }
+}
+
+/* This collection group will collect the CPU status info every 20 secs.
+   The time threshold is set to 90 seconds.  In honesty, this
+   time_threshold could be set significantly higher to reduce
+   unneccessary  network chatter. */
+collection_group {
+  collect_every = 20
+  time_threshold = 90
+  /* CPU status */
+  metric {
+    name = "cpu_user"
+    value_threshold = "1.0"
+    title = "CPU User"
+  }
+  metric {
+    name = "cpu_system"
+    value_threshold = "1.0"
+    title = "CPU System"
+  }
+  metric {
+    name = "cpu_idle"
+    value_threshold = "5.0"
+    title = "CPU Idle"
+  }
+  metric {
+    name = "cpu_nice"
+    value_threshold = "1.0"
+    title = "CPU Nice"
+  }
+  metric {
+    name = "cpu_aidle"
+    value_threshold = "5.0"
+    title = "CPU aidle"
+  }
+  metric {
+    name = "cpu_wio"
+    value_threshold = "1.0"
+    title = "CPU wio"
+  }
+  /* The next two metrics are optional if you want more detail...
+     ... since they are accounted for in cpu_system.
+  metric {
+    name = "cpu_intr"
+    value_threshold = "1.0"
+    title = "CPU intr"
+  }
+  metric {
+    name = "cpu_sintr"
+    value_threshold = "1.0"
+    title = "CPU sintr"
+  }
+  */
+}
+
+collection_group {
+  collect_every = 20
+  time_threshold = 90
+  /* Load Averages */
+  metric {
+    name = "load_one"
+    value_threshold = "1.0"
+    title = "One Minute Load Average"
+  }
+  metric {
+    name = "load_five"
+    value_threshold = "1.0"
+    title = "Five Minute Load Average"
+  }
+  metric {
+    name = "load_fifteen"
+    value_threshold = "1.0"
+    title = "Fifteen Minute Load Average"
+  }
+}
+
+/* This group collects the number of running and total processes */
+collection_group {
+  collect_every = 80
+  time_threshold = 950
+  metric {
+    name = "proc_run"
+    value_threshold = "1.0"
+    title = "Total Running Processes"
+  }
+  metric {
+    name = "proc_total"
+    value_threshold = "1.0"
+    title = "Total Processes"
+  }
+}
+
+/* This collection group grabs the volatile memory metrics every 40 secs and
+   sends them at least every 180 secs.  This time_threshold can be increased
+   significantly to reduce unneeded network traffic. */
+collection_group {
+  collect_every = 40
+  time_threshold = 180
+  metric {
+    name = "mem_free"
+    value_threshold = "1024.0"
+    title = "Free Memory"
+  }
+  metric {
+    name = "mem_shared"
+    value_threshold = "1024.0"
+    title = "Shared Memory"
+  }
+  metric {
+    name = "mem_buffers"
+    value_threshold = "1024.0"
+    title = "Memory Buffers"
+  }
+  metric {
+    name = "mem_cached"
+    value_threshold = "1024.0"
+    title = "Cached Memory"
+  }
+  metric {
+    name = "swap_free"
+    value_threshold = "1024.0"
+    title = "Free Swap Space"
+  }
+}
+
+collection_group {
+  collect_every = 40
+  time_threshold = 300
+  metric {
+    name = "bytes_out"
+    value_threshold = 4096
+    title = "Bytes Sent"
+  }
+  metric {
+    name = "bytes_in"
+    value_threshold = 4096
+    title = "Bytes Received"
+  }
+  metric {
+    name = "pkts_in"
+    value_threshold = 256
+    title = "Packets Received"
+  }
+  metric {
+    name = "pkts_out"
+    value_threshold = 256
+    title = "Packets Sent"
+  }
+}
+
+/* Different than 2.5.x default since the old config made no sense */
+collection_group {
+  collect_every = 1800
+  time_threshold = 3600
+  metric {
+    name = "disk_total"
+    value_threshold = 1.0
+    title = "Total Disk Space"
+  }
+}
+
+collection_group {
+  collect_every = 40
+  time_threshold = 180
+  metric {
+    name = "disk_free"
+    value_threshold = 1.0
+    title = "Disk Space Available"
+  }
+  metric {
+    name = "part_max_used"
+    value_threshold = 1.0
+    title = "Maximum Disk Space Used"
+  }
+}
+
+include ("${GANGLIA_CONF_DIR}/${gmondClusterName}/conf.d/*.conf")
+END_OF_GMOND_CORE_CONF
+        else
+            return 2;
+        fi
+    else
+        return 1;
+    fi
+}
+
+function generateGmondMasterConf
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
+
+        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
+        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
+        then
+            now=`date`;
+
+            cat << END_OF_GMOND_MASTER_CONF
+#################### Generated by ${0} on ${now} ####################
+/* Masters only receive; they never send. */
+udp_recv_channel {
+  bind = ${gmondMasterIP}
+  port = ${gmondPort}
+}
+
+/* The gmond cluster master must additionally provide an XML 
+ * description of the cluster to the gmetad that will query it.
+ */
+tcp_accept_channel {
+  bind = ${gmondMasterIP}
+  port = ${gmondPort}
+}
+END_OF_GMOND_MASTER_CONF
+        else
+            return 2;
+        fi
+    else
+        return 1;
+    fi
+}
+
+function generateGmondSlaveConf
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
+
+        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
+        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
+        then
+            now=`date`;
+
+            cat << END_OF_GMOND_SLAVE_CONF
+#################### Generated by ${0} on ${now} ####################
+/* Slaves only send; they never receive. */
+udp_send_channel {
+  #bind_hostname = yes # Highly recommended, soon to be default.
+                       # This option tells gmond to use a source address
+                       # that resolves to the machine's hostname.  Without
+                       # this, the metrics may appear to come from any
+                       # interface and the DNS names associated with
+                       # those IPs will be used to create the RRDs.
+  host = ${gmondMasterIP}
+  port = ${gmondPort}
+  ttl = 1
+}
+END_OF_GMOND_SLAVE_CONF
+        else
+            return 2;
+        fi
+    else
+        return 1;
+    fi
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/rrdcachedLib.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/rrdcachedLib.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/rrdcachedLib.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/rrdcachedLib.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get access to Ganglia-wide constants etc.
+source ./gangliaLib.sh;
+
+RRDCACHED_BIN=/usr/bin/rrdcached;
+RRDCACHED_PID_FILE=${GANGLIA_RUNTIME_DIR}/rrdcached.pid;
+RRDCACHED_ALL_ACCESS_UNIX_SOCKET=${GANGLIA_RUNTIME_DIR}/rrdcached.sock;
+RRDCACHED_LIMITED_ACCESS_UNIX_SOCKET=${GANGLIA_RUNTIME_DIR}/rrdcached.limited.sock;
+
+function getRrdcachedLoggedPid()
+{
+    if [ -e "${RRDCACHED_PID_FILE}" ]
+    then
+        echo `cat ${RRDCACHED_PID_FILE}`;
+    fi
+}
+
+function getRrdcachedRunningPid()
+{
+    rrdcachedLoggedPid=`getRrdcachedLoggedPid`;
+
+    if [ -n "${rrdcachedLoggedPid}" ]
+    then
+        echo `ps -o pid=MYPID -p ${rrdcachedLoggedPid} | tail -1 | awk '{print $1}' | grep -v MYPID`;
+    fi
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/setupGanglia.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/setupGanglia.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/setupGanglia.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/setupGanglia.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,128 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get access to Ganglia-wide constants, utilities etc.
+source ./gangliaLib.sh
+
+function usage()
+{
+  cat << END_USAGE
+Usage: ${0} [-c <gmondClusterName> [-m]] [-t]
+
+Options:
+  -c <gmondClusterName>   The name of the Ganglia Cluster whose gmond configuration we're here to generate.
+
+  -m                      Whether this gmond (if -t is not specified) is the master for its Ganglia 
+                          Cluster. Without this, we generate slave gmond configuration.
+
+  -t                      Whether this is a call to generate gmetad configuration (as opposed to the
+                          gmond configuration that is generated without this).
+END_USAGE
+}
+
+function instantiateGmetadConf()
+{
+  # gmetad utility library.
+  source ./gmetadLib.sh;
+
+  generateGmetadConf > ${GMETAD_CONF_FILE};
+}
+
+function instantiateGmondConf()
+{
+  # gmond utility library.
+  source ./gmondLib.sh;
+ 
+  gmondClusterName=${1};
+
+  if [ "x" != "x${gmondClusterName}" ]
+  then
+
+    createDirectory "${GANGLIA_RUNTIME_DIR}/${gmondClusterName}";
+    createDirectory "${GANGLIA_CONF_DIR}/${gmondClusterName}/conf.d";
+    
+    # Always blindly generate the core gmond config - that goes on every box running gmond. 
+    generateGmondCoreConf ${gmondClusterName} > `getGmondCoreConfFileName ${gmondClusterName}`;
+
+    isMasterGmond=${2};
+
+    # Decide whether we want to add on the master or slave gmond config.
+    if [ "0" -eq "${isMasterGmond}" ]
+    then
+      generateGmondSlaveConf ${gmondClusterName} > `getGmondSlaveConfFileName ${gmondClusterName}`;
+    else
+      generateGmondMasterConf ${gmondClusterName} > `getGmondMasterConfFileName ${gmondClusterName}`;
+    fi
+
+  else
+    echo "No gmondClusterName passed in, nothing to instantiate";
+  fi
+}
+
+# main()
+
+gmondClusterName=;
+isMasterGmond=0;
+configureGmetad=0;
+
+while getopts ":c:mt" OPTION
+do
+  case ${OPTION} in
+    c) 
+      gmondClusterName=${OPTARG};
+      ;;
+    m)
+      isMasterGmond=1;
+      ;;
+    t)
+      configureGmetad=1;
+      ;;
+    ?)
+      usage;
+      exit 1;
+  esac
+done
+
+# Initialization.
+createDirectory ${GANGLIA_CONF_DIR};
+createDirectory ${GANGLIA_RUNTIME_DIR};
+# So rrdcached can drop its PID files in here.
+chmod a+w ${GANGLIA_RUNTIME_DIR};
+
+if [ -n "${gmondClusterName}" ]
+then
+
+  # Be forgiving of users who pass in -c along with -t (which always takes precedence).
+  if [ "1" -eq "${configureGmetad}" ]
+  then
+    instantiateGmetadConf;
+  else
+    instantiateGmondConf ${gmondClusterName} ${isMasterGmond};
+  fi
+
+elif [ "1" -eq "${configureGmetad}" ]
+then
+  instantiateGmetadConf;
+else
+  usage;
+  exit 2;
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmetad.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmetad.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmetad.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmetad.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get all our common constants etc. set up.
+source ./gmetadLib.sh;
+
+# To get access to ${RRDCACHED_ALL_ACCESS_UNIX_SOCKET}.
+source ./rrdcachedLib.sh;
+
+# Before starting gmetad, start rrdcached.
+./startRrdcached.sh;
+
+if [ $? -eq 0 ] 
+then
+    gmetadRunningPid=`getGmetadRunningPid`;
+
+    # Only attempt to start gmetad if there's not already one running.
+    if [ -z "${gmetadRunningPid}" ]
+    then
+        env RRDCACHED_ADDRESS=${RRDCACHED_ALL_ACCESS_UNIX_SOCKET} \
+                    ${GMETAD_BIN} --conf=${GMETAD_CONF_FILE} --pid-file=${GMETAD_PID_FILE};
+
+        gmetadRunningPid=`getGmetadRunningPid`;
+
+        if [ -n "${gmetadRunningPid}" ]
+        then
+            echo "Started ${GMETAD_BIN} with PID ${gmetadRunningPid}";
+        else
+            echo "Failed to start ${GMETAD_BIN}";
+            exit 1;
+        fi
+    else
+        echo "${GMETAD_BIN} already running with PID ${gmetadRunningPid}";
+    fi
+else
+    echo "Not starting ${GMETAD_BIN} because starting ${RRDCACHED_BIN} failed.";
+    exit 2;
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmond.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmond.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmond.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startGmond.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get all our common constants etc. set up.
+# Pulls in gangliaLib.sh as well, so we can skip pulling it in again.
+source ./gmondLib.sh;
+
+function startGmondForCluster()
+{
+    gmondClusterName=${1};
+
+    gmondRunningPid=`getGmondRunningPid ${gmondClusterName}`;
+
+    # Only attempt to start gmond if there's not already one running.
+    if [ -z "${gmondRunningPid}" ]
+    then
+      gmondCoreConfFileName=`getGmondCoreConfFileName ${gmondClusterName}`;
+
+      if [ -e "${gmondCoreConfFileName}" ]
+      then 
+        gmondPidFileName=`getGmondPidFileName ${gmondClusterName}`;
+
+        ${GMOND_BIN} --conf=${gmondCoreConfFileName} --pid-file=${gmondPidFileName};
+  
+        gmondRunningPid=`getGmondRunningPid ${gmondClusterName}`;
+  
+        if [ -n "${gmondRunningPid}" ]
+        then
+            echo "Started ${GMOND_BIN} for cluster ${gmondClusterName} with PID ${gmondRunningPid}";
+        else
+            echo "Failed to start ${GMOND_BIN} for cluster ${gmondClusterName}";
+            exit 1;
+        fi
+      fi 
+    else
+      echo "${GMOND_BIN} for cluster ${gmondClusterName} already running with PID ${gmondRunningPid}";
+    fi
+}
+
+# main()
+gmondClusterName=${1};
+
+if [ "x" == "x${gmondClusterName}" ]
+then
+    # No ${gmondClusterName} passed in as command-line arg, so start 
+    # all the gmonds we know about.
+    for gmondClusterName in `getConfiguredGangliaClusterNames`
+    do
+        startGmondForCluster ${gmondClusterName};
+    done
+else
+    # Just start the one ${gmondClusterName} that was asked for.
+    startGmondForCluster ${gmondClusterName};
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startRrdcached.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startRrdcached.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startRrdcached.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/startRrdcached.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Slurp in all our user-customizable settings.
+source ./gangliaEnv.sh;
+
+# Get all our common constants etc. set up.
+source ./rrdcachedLib.sh;
+
+rrdcachedRunningPid=`getRrdcachedRunningPid`;
+
+# Only attempt to start rrdcached if there's not already one running.
+if [ -z "${rrdcachedRunningPid}" ]
+then
+    #changed because problem puppet had with nobody user
+    #sudo -u ${GMETAD_USER} ${RRDCACHED_BIN} -p ${RRDCACHED_PID_FILE} \
+    #         -m 664 -l unix:${RRDCACHED_ALL_ACCESS_UNIX_SOCKET} \
+    #         -m 777 -P FLUSH,STATS,HELP -l unix:${RRDCACHED_LIMITED_ACCESS_UNIX_SOCKET} \
+    #         -b /var/lib/ganglia/rrds -B
+    su - ${GMETAD_USER} -c "${RRDCACHED_BIN} -p ${RRDCACHED_PID_FILE} \
+             -m 664 -l unix:${RRDCACHED_ALL_ACCESS_UNIX_SOCKET} \
+             -m 777 -P FLUSH,STATS,HELP -l unix:${RRDCACHED_LIMITED_ACCESS_UNIX_SOCKET} \
+             -b /var/lib/ganglia/rrds -B"
+
+    # Ideally, we'd use ${RRDCACHED_BIN}'s -s ${WEBSERVER_GROUP} option for 
+    # this, but it doesn't take sometimes due to a lack of permissions,
+    # so perform the operation explicitly to be super-sure.
+    chgrp ${WEBSERVER_GROUP} ${RRDCACHED_ALL_ACCESS_UNIX_SOCKET};
+    chgrp ${WEBSERVER_GROUP} ${RRDCACHED_LIMITED_ACCESS_UNIX_SOCKET};
+
+    # Check to make sure rrdcached actually started up.
+    rrdcachedRunningPid=`getRrdcachedRunningPid`;
+
+    if [ -n "${rrdcachedRunningPid}" ]
+    then
+        echo "Started ${RRDCACHED_BIN} with PID ${rrdcachedRunningPid}";
+    else
+        echo "Failed to start ${RRDCACHED_BIN}";
+        exit 1;
+    fi
+else
+    echo "${RRDCACHED_BIN} already running with PID ${rrdcachedRunningPid}";
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmetad.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmetad.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmetad.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmetad.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get all our common constants etc. set up.
+source ./gmetadLib.sh;
+
+gmetadRunningPid=`getGmetadRunningPid`;
+
+# Only go ahead with the termination if we could find a running PID.
+if [ -n "${gmetadRunningPid}" ]
+then
+    kill -KILL ${gmetadRunningPid};
+    echo "Stopped ${GMETAD_BIN} (with PID ${gmetadRunningPid})";
+fi
+
+# Poll again.
+gmetadRunningPid=`getGmetadRunningPid`;
+
+# Once we've killed gmetad, there should no longer be a running PID.
+if [ -z "${gmetadRunningPid}" ]
+then
+    # It's safe to stop rrdcached now.
+    ./stopRrdcached.sh;
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmond.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmond.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmond.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopGmond.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get all our common constants etc. set up.
+# Pulls in gangliaLib.sh as well, so we can skip pulling it in again.
+source ./gmondLib.sh;
+
+function stopGmondForCluster()
+{
+    gmondClusterName=${1};
+
+    gmondRunningPid=`getGmondRunningPid ${gmondClusterName}`;
+
+    # Only go ahead with the termination if we could find a running PID.
+    if [ -n "${gmondRunningPid}" ]
+    then
+      kill -HUP ${gmondRunningPid};
+      echo "Stopped ${GMOND_BIN} for cluster ${gmondClusterName} (with PID ${gmondRunningPid})";
+    fi
+}
+
+# main()
+gmondClusterName=${1};
+
+if [ "x" == "x${gmondClusterName}" ]
+then
+    # No ${gmondClusterName} passed in as command-line arg, so stop
+    # all the gmonds we know about.
+    for gmondClusterName in `getConfiguredGangliaClusterNames`
+    do
+        stopGmondForCluster ${gmondClusterName};
+    done
+else
+    stopGmondForCluster ${gmondClusterName};
+fi

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopRrdcached.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopRrdcached.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopRrdcached.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/stopRrdcached.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get all our common constants etc. set up.
+source ./rrdcachedLib.sh;
+
+rrdcachedRunningPid=`getRrdcachedRunningPid`;
+
+# Only go ahead with the termination if we could find a running PID.
+if [ -n "${rrdcachedRunningPid}" ]
+then
+    kill -TERM ${rrdcachedRunningPid};
+    # ${RRDCACHED_BIN} takes a few seconds to drain its buffers, so wait 
+    # until we're sure it's well and truly dead. 
+    #
+    # Without this, an immediately following startRrdcached.sh won't do
+    # anything, because it still sees this soon-to-die instance alive,
+    # and the net result is that after a few seconds, there's no
+    # ${RRDCACHED_BIN} running on the box anymore.
+    sleep 5;
+    echo "Stopped ${RRDCACHED_BIN} (with PID ${rrdcachedRunningPid})";
+fi 

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/teardownGanglia.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/teardownGanglia.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/teardownGanglia.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/files/teardownGanglia.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+# Get access to Ganglia-wide constants, utilities etc.
+source ./gangliaLib.sh;
+
+# Undo what we did while setting up Ganglia on this box.
+rm -rf ${GANGLIA_CONF_DIR};
+rm -rf ${GANGLIA_RUNTIME_DIR};

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,59 @@
+class hdp2-ganglia::config(
+  $ganglia_server_host = undef,
+  $service_state = $hdp2::params::cluster_service_state
+)
+{
+ if ($service_state in ['running','installed_and_configured','stopped']) {
+    #TODO: divide into what is needed on server vs what is needed on monitored nodes
+    $shell_cmds_dir = $hdp2-ganglia::params::ganglia_shell_cmds_dir
+    $shell_files = ['checkGmond.sh','checkRrdcached.sh','gmetadLib.sh','gmondLib.sh','rrdcachedLib.sh' ,'setupGanglia.sh','startGmetad.sh','startGmond.sh','startRrdcached.sh','stopGmetad.sh','stopGmond.sh','stopRrdcached.sh','teardownGanglia.sh']
+
+    hdp2::directory_recursive_create { $shell_cmds_dir :
+      owner => root,
+      group => root
+    } 
+
+     hdp2-ganglia::config::init_file { ['gmetad','gmond']: }
+
+     hdp2-ganglia::config::shell_file { $shell_files: }                       
+
+     hdp2-ganglia::config::file { ['gangliaClusters.conf','gangliaEnv.sh','gangliaLib.sh']: 
+       ganglia_server_host => $ganglia_server_host
+     }
+ 
+     anchor{'hdp2-ganglia::config::begin':} -> Hdp2::Directory_recursive_create[$shell_cmds_dir] -> Hdp2-ganglia::Config::Shell_file<||> -> anchor{'hdp2-ganglia::config::end':}
+     Anchor['hdp2-ganglia::config::begin'] -> Hdp2-ganglia::Config::Init_file<||> -> Anchor['hdp2-ganglia::config::end']
+     Anchor['hdp2-ganglia::config::begin'] -> Hdp2-ganglia::Config::File<||> -> Anchor['hdp2-ganglia::config::end']
+  }
+}
+
+define hdp2-ganglia::config::shell_file()
+{
+  file { "${hdp2-ganglia::params::ganglia_shell_cmds_dir}/${name}":
+    source => "puppet:///modules/hdp2-ganglia/${name}", 
+    mode => '0755'
+  }
+}
+
+define hdp2-ganglia::config::init_file()
+{
+  file { "/etc/init.d/hdp-${name}":
+    source => "puppet:///modules/hdp2-ganglia/${name}.init", 
+    mode => '0755'
+  }
+}
+
+### config files
+define hdp2-ganglia::config::file(
+  $ganglia_server_host = undef
+)
+{
+  hdp2::configfile { "${hdp2-ganglia::params::ganglia_shell_cmds_dir}/${name}":
+    component           => 'ganglia',
+    owner               => root,
+    group               => root
+  }
+  if ($ganglia_server_host != undef) {
+    Hdp2::Configfile<||>{ganglia_server_host => $ganglia_server_host}
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_monitor.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_monitor.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_monitor.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_monitor.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,21 @@
+#TODO: these scripts called shoudl be converetd to native puppet
+define hdp2-ganglia::config::generate_monitor(
+  $ganglia_service,
+  $role
+)
+{
+  $shell_cmds_dir = $hdp2-ganglia::params::ganglia_shell_cmds_dir
+  $cmd = $ganglia_service ? {
+    'gmond'  => $role ? {
+      'server' => "${shell_cmds_dir}/setupGanglia.sh -c ${name} -m",
+       default =>  "${shell_cmds_dir}/setupGanglia.sh -c ${name}"
+    },
+    'gmetad' => "${shell_cmds_dir}/setupGanglia.sh -t",
+     default => hdp_fail("Unexpected ganglia service: ${$ganglia_service}")	
+  }
+
+  #TODO: put in test condition
+  hdp::exec { $cmd:
+    command => $cmd
+ }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_server.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_server.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/config/generate_server.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,22 @@
+#TODO: these scripts called shoudl be converetd to native puppet
+define hdp2-ganglia::config::generate_server(
+  $ganglia_service,
+  $role
+)
+{
+  $shell_cmds_dir = $hdp2-ganglia::params::ganglia_shell_cmds_dir
+
+  $cmd = $ganglia_service ? {
+    'gmond'  => $role ? {
+      'server' => "${shell_cmds_dir}/setupGanglia.sh -c ${name} -m",
+       default =>  "${shell_cmds_dir}/setupGanglia.sh -c ${name}"
+    },
+    'gmetad' => "${shell_cmds_dir}/setupGanglia.sh -t",
+     default => hdp_fail("Unexpected ganglia service: ${$ganglia_service}")	
+  }
+
+  #TODO: put in test condition
+  hdp::exec { $cmd:
+    command => $cmd
+ }
+}

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

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

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/init.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/init.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/init.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,17 @@
+class hdp2-ganglia(
+  $service_state
+)
+{
+  if (($service_state != 'no_op') or ($service_state != 'uninstalled')) {
+    include hdp2-ganglia::params
+    $gmetad_user = $hdp2-ganglia::params::gmetad_user
+    $gmond_user = $hdp2-ganglia::params::gmond_user
+  
+    user { $gmond_user : shell => '/bin/bash'} #provision for nobody user
+    if ( $gmetad_user != $gmond_user) {
+      user { $gmetad_user : shell => '/bin/bash'} #provision for nobody user
+    }
+    anchor{'hdp2-ganglia::begin':} -> User<|title == $gmond_user or title == $gmetad_user|> ->  anchor{'hdp2-ganglia::end':}
+  }
+}
+

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,95 @@
+class hdp2-ganglia::monitor(
+  $service_state = $hdp2::params::cluster_service_state,
+  $ganglia_server_host = undef,
+  $opts = {}
+) inherits hdp2-ganglia::params
+{
+  if  ($service_state == 'no_op') {
+  } elsif ($service_state == 'uninstalled') {     
+
+   hdp2::package { 'ganglia-monitor':         
+       ensure      => 'uninstalled', 
+      java_needed => false      
+   }
+
+  } else {
+    if ($hdp2::params::service_exists['hdp2-ganglia::server'] != true) {
+      class { 'hdp2-ganglia':
+       service_state => $service_state
+      }
+    }
+
+    hdp2::package { 'ganglia-monitor': }
+
+    if ($hdp2::params::service_exists['hdp2-ganglia::server'] != true) {
+      class { 'hdp2-ganglia::config': ganglia_server_host => $ganglia_server_host}
+    }
+
+#    if (($hdp2::params::service_exists['hdp-hadoop::datanode'] == true) or ($hdp2::params::service_exists['hdp-hadoop::namenode'] == true) or ($hdp2::params::service_exists['hdp-hadoop::jobtracker'] == true) or ($hdp2::params::service_exists['hdp-hadoop::tasktracker'] == true) or ($hdp2::params::service_exists['hdp-hadoop::client'] == true) or ($hdp2::params::service_exists['hdp-hadoop::snamenode'] == true)) {
+#     class { 'hdp-hadoop::enable-ganglia': }
+#   }
+
+    if ($service_exists['hdp-hbase::master'] == true) {
+      class { 'hdp-hbase::master::enable-ganglia': }
+    }
+  
+    if ($service_exists['hdp-hbase::regionserver'] == true) {
+      class { 'hdp-hbase::regionserver::enable-ganglia': }
+    }
+
+    class { 'hdp2-ganglia::monitor::config-gen': }
+  
+    class { 'hdp2-ganglia::monitor::gmond': ensure => $service_state}
+
+    if ($hdp2::params::service_exists['hdp2-ganglia::server'] != true) {
+      Class['hdp2-ganglia'] -> Hdp2::Package['ganglia-monitor'] -> Class['hdp2-ganglia::config'] -> 
+      Class['hdp2-ganglia::monitor::config-gen'] -> Class['hdp2-ganglia::monitor::gmond']
+    } else {
+      Hdp2::Package['ganglia-monitor'] ->  Class['hdp2-ganglia::monitor::config-gen'] -> Class['hdp2-ganglia::monitor::gmond']
+    }
+  }
+}
+
+
+class hdp2-ganglia::monitor::config-gen()
+{
+
+  $service_exists = $hdp2::params::service_exists
+
+  if ($service_exists['hdp2-hadoop::namenode'] == true) {
+    hdp2-ganglia::config::generate_monitor { 'HDPNameNode':}
+  }
+  if ($service_exists['hdp2-hadoop::resourcemanager'] == true){
+    hdp2-ganglia::config::generate_monitor { 'HDPResourceManager':}
+  }
+  if ($service_exists['hdp2-hbase::master'] == true) {
+    hdp2-ganglia::config::generate_monitor { 'HDPHBaseMaster':}
+  }
+  if ($service_exists['hdp2-hadoop::datanode'] == true) {
+    hdp2-ganglia::config::generate_monitor { 'HDPSlaves':}
+  }
+  Hdp2-ganglia::Config::Generate_monitor<||>{
+    ganglia_service => 'gmond',
+    role => 'monitor'
+  }
+   # 
+  anchor{'hdp2-ganglia::monitor::config-gen::begin':} -> Hdp2-ganglia::Config::Generate_monitor<||> -> anchor{'hdp2-ganglia::monitor::config-gen::end':}
+}
+
+class hdp2-ganglia::monitor::gmond(
+  $ensure
+  )
+{
+  if ($ensure == 'running') {
+    $command = "service hdp-gmond start >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1"
+   } elsif  ($ensure == 'stopped') {
+    $command = "service hdp-gmond stop >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1"
+  }
+  if ($ensure == 'running' or $ensure == 'stopped') {
+    hdp::exec { "hdp-gmond service" :
+      command => "$command",
+      unless => "/bin/ps auwx | /bin/grep [g]mond",
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'
+    }
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor_and_server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor_and_server.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor_and_server.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/monitor_and_server.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,70 @@
+class hdp2-ganglia::monitor_and_server(
+  $service_state = $hdp2::params::cluster_service_state,
+  $opts = {}
+) inherits hdp2-ganglia::params
+{
+  $ganglia_shell_cmds_dir = $hdp2-ganglia::params::ganglia_shell_cmds_dir
+  $ganglia_conf_dir = $hdp2-ganglia::params::ganglia_conf_dir
+  $ganglia_runtime_dir = $hdp2-ganglia::params::ganglia_runtime_dir
+
+  #note: includes the common package ganglia-monitor
+  class { 'hdp2-ganglia':
+    service_state => $service_state
+  }
+
+  if ($service_state == 'no_op') {
+  } elsif ($service_state in ['uninstalled']) {
+    class { 'hdp2-ganglia::server::packages':
+      ensure => 'uninstalled'
+      }
+
+    hdp::directory { [$ganglia_conf_dir,$ganglia_runtime_dir]:
+      service_state => $service_state,
+      force => true
+    }
+    
+    class { 'hdp2-ganglia::config':
+      service_state => $service_state
+    }
+
+    Class['hdp2-ganglia'] -> Class['hdp2-ganglia::server::packages'] -> 
+      Hdp2::Directory[$ganglia_conf_dir] -> Hdp2::Directory[$ganglia_runtime_dir] ->
+      Class['hdp2-ganglia::config']
+  } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+    class { 'hdp2-ganglia::server::packages': }
+
+    class { 'hdp2-ganglia::config': 
+     ganglia_server_host => $hdp2::params::host_address,
+     service_state       => $service_state
+     }
+
+    class {'hdp2-ganglia::monitor::config-gen': }      
+
+    class {'hdp2-ganglia::server::config-gen': }      
+    
+    hdp2-ganglia::config::generate_server { 'gmetad':
+      ganglia_service => 'gmetad'
+    }
+
+    class { 'hdp2-ganglia::service::gmond': 
+      ensure => $service_state
+    }
+
+    class { 'hdp2-ganglia::server::services' : 
+      service_state => $service_state,
+      monitor_and_server_single_node => true
+    }
+
+    class { 'hdp2-ganglia::service::change_permission':
+      ensure => $service_state
+    }
+
+    #top level no anchors needed
+    Class['hdp2-ganglia'] -> Class['hdp2-ganglia::server::packages'] -> Class['hdp2-ganglia::config'] -> 
+      Class['hdp2-ganglia::monitor::config-gen'] -> Class['hdp2-ganglia::server::config-gen'] -> Hdp2-ganglia::Config::Generate_server['gmetad'] ->
+      Class['hdp2-ganglia::service::gmond'] -> Class['hdp2-ganglia::server::services'] ->
+      Class['hdp2-ganglia::service::change_permission']
+  } else {
+    hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/params.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/params.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/params.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,12 @@
+class hdp2-ganglia::params() inherits hdp2::params
+{
+  $ganglia_conf_dir = "/etc/ganglia/hdp"
+  $ganglia_runtime_dir = "/var/run/ganglia/hdp"
+
+  $ganglia_shell_cmds_dir = hdp_default("ganglia_shell_cmd_dir","/usr/libexec/hdp/ganglia")
+  
+  $gmetad_user = $hdp2::params::gmetad_user
+  $gmond_user = $hdp2::params::gmond_user
+
+  $webserver_group = hdp_default("hadoop/gangliaEnv/webserver_group","apache")
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/server.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/server.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/manifests/server.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,84 @@
+class hdp2-ganglia::server(
+  $service_state = $hdp2::params::cluster_service_state,
+  $opts = {}
+) inherits  hdp2-ganglia::params
+{
+  $hdp2::params::service_exists['hdp2-ganglia::server'] = true
+
+  if ($service_state == 'no_op') {
+  } elsif ($service_state == 'uninstalled') {
+
+   class { 'hdp2-ganglia::server::packages':
+      ensure => 'uninstalled'
+   }
+
+  } else {
+  class { 'hdp2-ganglia':
+    service_state => $service_state
+  }
+
+  class { 'hdp2-ganglia::server::packages': }
+
+  class { 'hdp2-ganglia::config': 
+    ganglia_server_host => $hdp2::params::host_address,
+    service_state       => $service_state 
+  }
+
+  hdp2-ganglia::config::generate_server { ['HDPNameNode','HDPResourceManager','HDPHBaseMaster','HDPSlaves']:
+    ganglia_service => 'gmond',
+    role => 'server'
+  }
+  hdp2-ganglia::config::generate_server { 'gmetad':
+    ganglia_service => 'gmetad',
+    role => 'server'
+  }
+
+  class { 'hdp2-ganglia::server::gmetad': ensure => $service_state}
+
+  class { 'hdp2-ganglia::service::change_permission': ensure => $service_state }
+
+  #top level does not need anchors
+  Class['hdp2-ganglia'] -> Class['hdp2-ganglia::server::packages'] -> Class['hdp2-ganglia::config'] -> 
+    Hdp2-ganglia::Config::Generate_server<||> -> Class['hdp2-ganglia::server::gmetad'] -> Class['hdp2-ganglia::service::change_permission']
+ }
+}
+
+class hdp2-ganglia::server::packages(
+  $ensure = present 
+)
+{
+  hdp2::package { ['ganglia-server','ganglia-gweb','ganglia-hdp-gweb-addons']: 
+    ensure      => $ensure,
+    java_needed => false  
+  } 
+}
+
+
+class hdp2-ganglia::service::change_permission(
+  $ensure
+)
+{
+  if ($ensure == 'running' or $ensure == 'installed_and_configured') {
+    hdp2::directory_recursive_create { '/var/lib/ganglia/dwoo' :
+      mode => '0777'
+      }
+  }
+}
+
+class hdp2-ganglia::server::gmetad(
+  $ensure
+)
+{
+  if ($ensure == 'running') {
+    $command = "service hdp-gmetad start >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1"
+   } elsif  ($ensure == 'stopped') {
+    $command = "service hdp-gmetad stop >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1"
+  }
+  if ($ensure == 'running' or $ensure == 'stopped') {
+    hdp::exec { "hdp-gmetad service" :
+      command => "$command",
+      unless => "/bin/ps auwx | /bin/grep [g]metad",
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'
+    }
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaClusters.conf.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaClusters.conf.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaClusters.conf.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaClusters.conf.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,25 @@
+#/*
+# * 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.
+# */
+
+#########################################################
+### ClusterName           GmondMasterHost   GmondPort ###
+#########################################################
+    HDPSlaves		<%=scope.function_hdp_host("ganglia_server_host")%>  8660
+    HDPNameNode         <%=scope.function_hdp_host("ganglia_server_host")%>  8661
+    HDPResourceManager  <%=scope.function_hdp_host("ganglia_server_host")%>  8662
+    HDPHBaseMaster	<%=scope.function_hdp_host("ganglia_server_host")%>  8663

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaEnv.sh.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaEnv.sh.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaEnv.sh.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaEnv.sh.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+# Unix users and groups for the binaries we start up.
+GMETAD_USER=<%=scope.function_hdp_template_var("gmetad_user")%>;
+GMOND_USER=<%=scope.function_hdp_template_var("gmond_user")%>;
+WEBSERVER_GROUP=<%=scope.function_hdp_template_var("webserver_group")%>;

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaLib.sh.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaLib.sh.erb?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaLib.sh.erb (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-ganglia/templates/gangliaLib.sh.erb Mon Oct 15 05:55:46 2012
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#/*
+# * 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.
+# */
+
+cd `dirname ${0}`;
+
+GANGLIA_CONF_DIR=<%=scope.function_hdp_template_var("ganglia_conf_dir")%>;
+GANGLIA_RUNTIME_DIR=<%=scope.function_hdp_template_var("ganglia_runtime_dir")%>;
+
+# This file contains all the info about each Ganglia Cluster in our Grid.
+GANGLIA_CLUSTERS_CONF_FILE=./gangliaClusters.conf;
+
+function createDirectory()
+{
+    directoryPath=${1};
+
+    if [ "x" != "x${directoryPath}" ]
+    then
+        mkdir -p ${directoryPath};
+    fi
+}
+
+function getGangliaClusterInfo()
+{
+    clusterName=${1};
+
+    if [ "x" != "x${clusterName}" ]
+    then
+        # Fetch the particular entry for ${clusterName} from ${GANGLIA_CLUSTERS_CONF_FILE}.
+        awk -v clusterName=${clusterName} '($1 !~ /^#/) && ($1 == clusterName)' ${GANGLIA_CLUSTERS_CONF_FILE};
+    else
+        # Spit out all the non-comment, non-empty lines from ${GANGLIA_CLUSTERS_CONF_FILE}.
+        awk '($1 !~ /^#/) && (NF)' ${GANGLIA_CLUSTERS_CONF_FILE};
+    fi
+}
+
+function getConfiguredGangliaClusterNames()
+{
+  # Find all the subdirectories in ${GANGLIA_CONF_DIR} and extract only 
+  # the subdirectory name from each.
+  if [ -e ${GANGLIA_CONF_DIR} ]
+  then  
+    find ${GANGLIA_CONF_DIR} -maxdepth 1 -mindepth 1 -type d | xargs -n1 basename;
+  fi
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/files/checkForFormat.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/files/checkForFormat.sh?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/files/checkForFormat.sh (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/files/checkForFormat.sh Mon Oct 15 05:55:46 2012
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+#
+
+export hdfs_user=$1
+shift
+export conf_dir=$1
+shift
+export mark_dir=$1
+shift
+export name_dirs=$*
+
+export EXIT_CODE=0
+export command="namenode -format"
+export list_of_non_empty_dirs=""
+
+mark_file=/var/run/hadoop/hdfs/namenode-formatted
+if [[ -f ${mark_file} ]] ; then
+  rm -f ${mark_file}
+  mkdir -p ${mark_dir}
+fi
+
+if [[ ! -d $mark_dir ]] ; then
+  for dir in `echo $name_dirs | tr ',' ' '` ; do
+    echo "NameNode Dirname = $dir"
+    cmd="ls $dir | wc -l  | grep -q ^0$"
+    eval $cmd
+    if [[ $? -ne 0 ]] ; then
+      (( EXIT_CODE = $EXIT_CODE + 1 ))
+      list_of_non_empty_dirs="$list_of_non_empty_dirs $dir"
+    fi
+  done
+
+  if [[ $EXIT_CODE == 0 ]] ; then
+    su - ${hdfs_user} -c "yes Y | hadoop --config ${conf_dir} ${command}"
+  else
+    echo "ERROR: Namenode directory(s) is non empty. Will not format the namenode. List of non-empty namenode dirs ${list_of_non_empty_dirs}"
+  fi
+else
+  echo "${mark_dir} exists. Namenode DFS already formatted"
+fi
+
+exit $EXIT_CODE
+

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/.directory
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/.directory?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/.directory (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/.directory Mon Oct 15 05:55:46 2012
@@ -0,0 +1,3 @@
+[Dolphin]
+Timestamp=2011,3,16,9,26,14
+ViewMode=1

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/client.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/client.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/client.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/client.pp Mon Oct 15 05:55:46 2012
@@ -0,0 +1,44 @@
+#
+#
+# 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-hadoop::client(
+  $service_state = $hdp2::params::cluster_client_state
+) inherits hdp2::params
+{
+  $hdp2::params::service_exists['hdp2-hadoop::client'] = true
+
+  Hdp2-hadoop::Common<||>{service_states +> $service_state}
+
+  if ($hdp2::params::use_32_bits_on_slaves == true) {
+    Hdp2-hadoop::Package<||>{include_32_bit => true}
+    Hdp2-hadoop::Configfile<||>{sizes +> 32}
+  } else {
+    Hdp2-hadoop::Package<||>{include_64_bit => true}
+    Hdp2-hadoop::Configfile<||>{sizes +> 64}
+  }
+
+  if ($service_state == 'no_op') {
+  } elsif ($service_state in ['installed_and_configured','uninstalled']) {
+    #adds package, users and directories, and common hadoop configs
+    include hdp2-hadoop::initialize
+  } else {
+    hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+  }
+}

Added: incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/datanode.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/datanode.pp?rev=1398196&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/datanode.pp (added)
+++ incubator/ambari/branches/branch-0.9-h2-dev/hmc/puppet/modules/hdp2-hadoop/manifests/datanode.pp 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.
+#
+#
+class hdp2-hadoop::datanode(
+  $service_state = $hdp2::params::cluster_service_state,
+  $opts = {}
+) inherits hdp2-hadoop::params 
+{
+
+  $hdp2::params::service_exists['hdp2-hadoop::datanode'] = true
+
+  Hdp2-hadoop::Common<||>{service_states +> $service_state}
+
+  if ($hdp2::params::use_32_bits_on_slaves == true) {
+    Hdp2-hadoop::Package<||>{include_32_bit => true}
+    Hdp2-hadoop::Configfile<||>{sizes +> 32}
+  } else {
+    Hdp2-hadoop::Package<||>{include_64_bit => true}
+    Hdp2-hadoop::Configfile<||>{sizes +> 64}
+  }
+
+  if ($service_state == 'no_op') {
+  } elsif ($service_state in ['running','stopped','installed_and_configured','uninstalled']) { 
+    $dfs_data_dir = $hdp2-hadoop::params::dfs_data_dir
+  
+    if (($hdp2::params::service_exists['hdp2-hadoop::namenode'] == true) or ($hdp2::params::service_exists['hdp2-hadoop::snamenode'] == true)){
+      $a_namenode_on_node = true
+    } else {
+      $a_namenode_on_node = false
+    }
+
+    #adds package, users and directories, and common hadoop configs
+    include hdp2-hadoop::initialize
+  
+    hdp2-hadoop::datanode::create_data_dirs { $dfs_data_dir: 
+      service_state => $service_state
+    }
+
+    if ($a_namenode_on_node == true){
+      $create_pid_dir = false
+      $create_log_dir = false
+    } else {
+      $create_pid_dir = true
+      $create_log_dir = true
+    }
+    
+    hdp2-hadoop::service{ 'datanode':
+      ensure         => $service_state,
+      user           => $hdp2-hadoop::params::hdfs_user,
+      create_pid_dir => $create_pid_dir,
+      create_log_dir => $create_log_dir
+    }
+    
+    #top level does not need anchors
+    Class['hdp2-hadoop'] -> Hdp2-hadoop::Service['datanode']
+    Hdp2-hadoop::Datanode::Create_data_dirs<||> -> Hdp2-hadoop::Service['datanode']
+  } else {
+    hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+  }
+}
+
+define hdp2-hadoop::datanode::create_data_dirs($service_state)
+{
+  $dirs = hdp_array_from_comma_list($name)
+  hdp2::directory_recursive_create { $dirs :
+    owner => $hdp2-hadoop::params::hdfs_user,
+    mode => '0750',
+    service_state => $service_state,
+    force => true
+  }
+}