You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/01/31 20:50:55 UTC
[30/51] [partial] AMBARI-4491. Move all the supported versions in
Baikal for stack to python code (remove dependence on puppet). (aonishuk)
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/gmondLib.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/gmondLib.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/gmondLib.sh
new file mode 100644
index 0000000..87da4dd
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/gmondLib.sh
@@ -0,0 +1,545 @@
+#!/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 total memory every
+ 180 secs.
+ This information doesn't change between reboots and is only collected
+ once. This information needed for heatmap showing */
+ collection_group {
+ collect_once = yes
+ time_threshold = 180
+ metric {
+ name = "mem_total"
+ title = "Memory Total"
+ }
+ }
+
+/* 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"
+ }
+ /* 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"
+ }
+}
+
+
+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"
+ }
+ metric {
+ name = "disk_total"
+ value_threshold = 1.0
+ title = "Total Disk Space"
+ }
+}
+
+udp_recv_channel {
+ port = 0
+}
+
+
+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
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrd.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrd.py
new file mode 100644
index 0000000..3fe6901
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrd.py
@@ -0,0 +1,213 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+
+import cgi
+import os
+import rrdtool
+import sys
+import time
+import re
+import urlparse
+
+# place this script in /var/www/cgi-bin of the Ganglia collector
+# requires 'yum install rrdtool-python' on the Ganglia collector
+
+
+def printMetric(clusterName, hostName, metricName, file, cf, start, end,
+ resolution, pointInTime):
+ if clusterName.endswith("rrds"):
+ clusterName = ""
+
+ args = [file, cf]
+
+ if start is not None:
+ args.extend(["-s", start])
+
+ if end is not None:
+ args.extend(["-e", end])
+
+ if resolution is not None:
+ args.extend(["-r", resolution])
+
+ rrdMetric = rrdtool.fetch(args)
+ # ds_name
+ sys.stdout.write(rrdMetric[1][0])
+ sys.stdout.write("\n")
+
+ sys.stdout.write(clusterName)
+ sys.stdout.write("\n")
+ sys.stdout.write(hostName)
+ sys.stdout.write("\n")
+ sys.stdout.write(metricName)
+ sys.stdout.write("\n")
+
+ # write time
+ sys.stdout.write(str(rrdMetric[0][0]))
+ sys.stdout.write("\n")
+ # write step
+ sys.stdout.write(str(rrdMetric[0][2]))
+ sys.stdout.write("\n")
+
+ if not pointInTime:
+ valueCount = 0
+ lastValue = None
+
+ for tuple in rrdMetric[2]:
+
+ thisValue = tuple[0]
+
+ if valueCount > 0 and thisValue == lastValue:
+ valueCount += 1
+ else:
+ if valueCount > 1:
+ sys.stdout.write("[~r]")
+ sys.stdout.write(str(valueCount))
+ sys.stdout.write("\n")
+
+ if thisValue is None:
+ sys.stdout.write("[~n]\n")
+ else:
+ sys.stdout.write(str(thisValue))
+ sys.stdout.write("\n")
+
+ valueCount = 1
+ lastValue = thisValue
+ else:
+ value = None
+ idx = -1
+ tuple = rrdMetric[2]
+ tupleLastIdx = len(tuple) * -1
+
+ while value is None and idx >= tupleLastIdx:
+ value = tuple[idx][0]
+ idx -= 1
+
+ if value is not None:
+ sys.stdout.write(str(value))
+ sys.stdout.write("\n")
+
+ sys.stdout.write("[~EOM]\n")
+ return
+
+
+def stripList(l):
+ return ([x.strip() for x in l])
+
+
+sys.stdout.write("Content-type: text/plain\n\n")
+
+# write start time
+sys.stdout.write(str(time.mktime(time.gmtime())))
+sys.stdout.write("\n")
+
+requestMethod = os.environ['REQUEST_METHOD']
+
+if requestMethod == 'POST':
+ postData = sys.stdin.readline()
+ queryString = cgi.parse_qs(postData)
+ queryString = dict((k, v[0]) for k, v in queryString.items())
+elif requestMethod == 'GET':
+ queryString = dict(cgi.parse_qsl(os.environ['QUERY_STRING']));
+
+if "m" in queryString:
+ metricParts = queryString["m"].split(",")
+else:
+ metricParts = [""]
+metricParts = stripList(metricParts)
+
+hostParts = []
+if "h" in queryString:
+ hostParts = queryString["h"].split(",")
+hostParts = stripList(hostParts)
+
+if "c" in queryString:
+ clusterParts = queryString["c"].split(",")
+else:
+ clusterParts = [""]
+clusterParts = stripList(clusterParts)
+
+if "p" in queryString:
+ rrdPath = queryString["p"]
+else:
+ rrdPath = "/var/lib/ganglia/rrds/"
+
+start = None
+if "s" in queryString:
+ start = queryString["s"]
+
+end = None
+if "e" in queryString:
+ end = queryString["e"]
+
+resolution = None
+if "r" in queryString:
+ resolution = queryString["r"]
+
+if "cf" in queryString:
+ cf = queryString["cf"]
+else:
+ cf = "AVERAGE"
+
+if "pt" in queryString:
+ pointInTime = True
+else:
+ pointInTime = False
+
+
+def _walk(*args, **kwargs):
+ for root, dirs, files in os.walk(*args, **kwargs):
+ for dir in dirs:
+ qualified_dir = os.path.join(root, dir)
+ if os.path.islink(qualified_dir):
+ for x in os.walk(qualified_dir, **kwargs):
+ yield x
+ yield (root, dirs, files)
+
+
+for cluster in clusterParts:
+ for path, dirs, files in _walk(rrdPath + cluster):
+ pathParts = path.split("/")
+ #Process only path which contains files. If no host parameter passed - process all hosts folders and summary info
+ #If host parameter passed - process only this host folder
+ if len(files) > 0 and (len(hostParts) == 0 or pathParts[-1] in hostParts):
+ for metric in metricParts:
+ file = metric + ".rrd"
+ fileFullPath = os.path.join(path, file)
+ if os.path.exists(fileFullPath):
+ #Exact name of metric
+ printMetric(pathParts[-2], pathParts[-1], file[:-4],
+ os.path.join(path, file), cf, start, end, resolution,
+ pointInTime)
+ else:
+ #Regex as metric name
+ metricRegex = metric + '\.rrd$'
+ p = re.compile(metricRegex)
+ matchedFiles = filter(p.match, files)
+ for matchedFile in matchedFiles:
+ printMetric(pathParts[-2], pathParts[-1], matchedFile[:-4],
+ os.path.join(path, matchedFile), cf, start, end,
+ resolution, pointInTime)
+
+sys.stdout.write("[~EOF]\n")
+# write end time
+sys.stdout.write(str(time.mktime(time.gmtime())))
+sys.stdout.write("\n")
+
+sys.stdout.flush
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrdcachedLib.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrdcachedLib.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrdcachedLib.sh
new file mode 100644
index 0000000..8b7c257
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/rrdcachedLib.sh
@@ -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
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/setupGanglia.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/setupGanglia.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/setupGanglia.sh
new file mode 100644
index 0000000..5145b9c
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/setupGanglia.sh
@@ -0,0 +1,141 @@
+#!/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] [-o <owner>] [-g <group>]
+
+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).
+ -o <owner> Owner
+ -g <group> Group
+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
+
+ chown -R ${3}:${4} ${GANGLIA_CONF_DIR}/${gmondClusterName}
+
+ else
+ echo "No gmondClusterName passed in, nothing to instantiate";
+ fi
+}
+
+# main()
+
+gmondClusterName=;
+isMasterGmond=0;
+configureGmetad=0;
+owner='root';
+group='root';
+
+while getopts ":c:mto:g:" OPTION
+do
+ case ${OPTION} in
+ c)
+ gmondClusterName=${OPTARG};
+ ;;
+ m)
+ isMasterGmond=1;
+ ;;
+ t)
+ configureGmetad=1;
+ ;;
+ o)
+ owner=${OPTARG};
+ ;;
+ g)
+ group=${OPTARG};
+ ;;
+ ?)
+ 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};
+chown ${owner}:${group} ${GANGLIA_CONF_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} ${owner} ${group};
+ fi
+
+elif [ "1" -eq "${configureGmetad}" ]
+then
+ instantiateGmetadConf;
+else
+ usage;
+ exit 2;
+fi
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmetad.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmetad.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmetad.sh
new file mode 100644
index 0000000..ab5102d
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmetad.sh
@@ -0,0 +1,64 @@
+#!/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};
+
+ for i in `seq 0 5`; do
+ gmetadRunningPid=`getGmetadRunningPid`;
+ if [ -n "${gmetadRunningPid}" ]
+ then
+ break;
+ fi
+ sleep 1;
+ done
+
+ 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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmond.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmond.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmond.sh
new file mode 100644
index 0000000..239b62e
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startGmond.sh
@@ -0,0 +1,80 @@
+#!/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};
+
+ for i in `seq 0 5`; do
+ gmondRunningPid=`getGmondRunningPid ${gmondClusterName}`;
+ if [ -n "${gmondRunningPid}" ]
+ then
+ break;
+ fi
+ sleep 1;
+ done
+
+ 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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startRrdcached.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startRrdcached.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startRrdcached.sh
new file mode 100644
index 0000000..e79472b
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/startRrdcached.sh
@@ -0,0 +1,69 @@
+#!/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 ${RRDCACHED_BASE_DIR} -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.
+ for i in `seq 0 5`; do
+ rrdcachedRunningPid=`getRrdcachedRunningPid`;
+ if [ -n "${rrdcachedRunningPid}" ]
+ then
+ break;
+ fi
+ sleep 1;
+ done
+
+ 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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmetad.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmetad.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmetad.sh
new file mode 100644
index 0000000..2764e0e
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmetad.sh
@@ -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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmond.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmond.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmond.sh
new file mode 100644
index 0000000..1af3eb9
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopGmond.sh
@@ -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 -KILL ${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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopRrdcached.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopRrdcached.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopRrdcached.sh
new file mode 100644
index 0000000..0a0d8d8
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/stopRrdcached.sh
@@ -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
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/teardownGanglia.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/teardownGanglia.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/teardownGanglia.sh
new file mode 100644
index 0000000..b27f7a2
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/files/teardownGanglia.sh
@@ -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};
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia.py
new file mode 100644
index 0000000..69fde27
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia.py
@@ -0,0 +1,97 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import *
+import os
+
+
+def groups_and_users():
+ import params
+
+def config():
+ import params
+
+ shell_cmds_dir = 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']
+ Directory(shell_cmds_dir,
+ owner="root",
+ group="root",
+ recursive=True
+ )
+ init_file("gmetad")
+ init_file("gmond")
+ for sh_file in shell_files:
+ shell_file(sh_file)
+ for conf_file in ['gangliaClusters.conf', 'gangliaEnv.sh', 'gangliaLib.sh']:
+ ganglia_TemplateConfig(conf_file)
+
+
+def init_file(name):
+ import params
+
+ File("/etc/init.d/hdp-" + name,
+ content=StaticFile(name + ".init"),
+ mode=0755
+ )
+
+
+def shell_file(name):
+ import params
+
+ File(params.ganglia_shell_cmds_dir + os.sep + name,
+ content=StaticFile(name),
+ mode=0755
+ )
+
+
+def ganglia_TemplateConfig(name, mode=0755, tag=None):
+ import params
+
+ TemplateConfig(format("{params.ganglia_shell_cmds_dir}/{name}"),
+ owner="root",
+ group="root",
+ template_tag=tag,
+ mode=mode
+ )
+
+
+def generate_daemon(ganglia_service,
+ name=None,
+ role=None,
+ owner=None,
+ group=None):
+ import params
+
+ cmd = ""
+ if ganglia_service == "gmond":
+ if role == "server":
+ cmd = "{params.ganglia_shell_cmds_dir}/setupGanglia.sh -c {name} -m -o {owner} -g {group}"
+ else:
+ cmd = "{params.ganglia_shell_cmds_dir}/setupGanglia.sh -c {name} -o {owner} -g {group}"
+ elif ganglia_service == "gmetad":
+ cmd = "{params.ganglia_shell_cmds_dir}/setupGanglia.sh -t -o {owner} -g {group}"
+ else:
+ raise Fail("Unexpected ganglia service")
+ Execute(format(cmd),
+ path=[params.ganglia_shell_cmds_dir, "/usr/sbin",
+ "/sbin:/usr/local/bin", "/bin", "/usr/bin"]
+ )
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor.py
new file mode 100644
index 0000000..4abdb9b
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor.py
@@ -0,0 +1,139 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import sys
+import os
+from os import path
+from resource_management import *
+from ganglia import generate_daemon
+import ganglia
+import ganglia_monitor_service
+
+
+class GangliaMonitor(Script):
+ def install(self, env):
+ import params
+
+ self.install_packages(env)
+ env.set_params(params)
+ self.configure(env)
+
+ def start(self, env):
+ ganglia_monitor_service.monitor("start")
+
+ def stop(self, env):
+ ganglia_monitor_service.monitor("stop")
+
+
+ def status(self, env):
+ import status_params
+ pid_file_name = 'gmond.pid'
+ pid_file_count = 0
+ pid_dir = status_params.pid_dir
+ # Recursively check all existing gmond pid files
+ for cur_dir, subdirs, files in os.walk(pid_dir):
+ for file_name in files:
+ if file_name == pid_file_name:
+ pid_file = os.path.join(cur_dir, file_name)
+ check_process_status(pid_file)
+ pid_file_count += 1
+ if pid_file_count == 0: # If no any pid file is present
+ raise ComponentIsNotRunning()
+
+
+ def configure(self, env):
+ import params
+
+ ganglia.groups_and_users()
+
+ Directory(params.ganglia_conf_dir,
+ owner="root",
+ group=params.user_group,
+ recursive=True
+ )
+
+ ganglia.config()
+
+ if params.is_namenode_master:
+ generate_daemon("gmond",
+ name = "HDPNameNode",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ if params.is_jtnode_master:
+ generate_daemon("gmond",
+ name = "HDPJobTracker",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ if params.is_rmnode_master:
+ generate_daemon("gmond",
+ name = "HDPResourceManager",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ if params.is_hsnode_master:
+ generate_daemon("gmond",
+ name = "HDPHistoryServer",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ if params.is_hbase_master:
+ generate_daemon("gmond",
+ name = "HDPHBaseMaster",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ pure_slave = not (params.is_namenode_master and
+ params.is_jtnode_master and
+ params.is_rmnode_master and
+ params.is_hsnode_master and
+ params.is_hbase_master) and params.is_slave
+ if pure_slave:
+ generate_daemon("gmond",
+ name = "HDPSlaves",
+ role = "monitor",
+ owner = "root",
+ group = params.user_group)
+
+ Directory(path.join(params.ganglia_dir, "conf.d"),
+ owner="root",
+ group=params.user_group
+ )
+
+ File(path.join(params.ganglia_dir, "conf.d/modgstatus.conf"),
+ owner="root",
+ group=params.user_group
+ )
+ File(path.join(params.ganglia_dir, "conf.d/multicpu.conf"),
+ owner="root",
+ group=params.user_group
+ )
+ File(path.join(params.ganglia_dir, "gmond.conf"),
+ owner="root",
+ group=params.user_group
+ )
+
+
+if __name__ == "__main__":
+ GangliaMonitor().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor_service.py
new file mode 100644
index 0000000..d86d894
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_monitor_service.py
@@ -0,0 +1,31 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import *
+
+
+def monitor(action=None):# 'start' or 'stop'
+ if action == "start":
+ Execute("chkconfig gmond off",
+ path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+ )
+ Execute(
+ format(
+ "service hdp-gmond {action} >> /tmp/gmond.log 2>&1 ; /bin/ps auwx | /bin/grep [g]mond >> /tmp/gmond.log 2>&1"),
+ path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'
+ )
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server.py
new file mode 100644
index 0000000..863f092
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server.py
@@ -0,0 +1,197 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import sys
+import os
+from os import path
+from resource_management import *
+from ganglia import generate_daemon
+import ganglia
+import ganglia_server_service
+
+
+class GangliaServer(Script):
+ def install(self, env):
+ import params
+
+ self.install_packages(env)
+ env.set_params(params)
+ self.configure(env)
+
+ def start(self, env):
+ import params
+
+ env.set_params(params)
+ ganglia_server_service.server("start")
+
+ def stop(self, env):
+ import params
+
+ env.set_params(params)
+ ganglia_server_service.server("stop")
+
+ def status(self, env):
+ import status_params
+ env.set_params(status_params)
+ pid_file = format("{pid_dir}/gmetad.pid")
+ # Recursively check all existing gmetad pid files
+ check_process_status(pid_file)
+
+ def configure(self, env):
+ import params
+
+ ganglia.groups_and_users()
+ ganglia.config()
+
+ if params.has_namenodes:
+ generate_daemon("gmond",
+ name = "HDPNameNode",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_jobtracker:
+ generate_daemon("gmond",
+ name = "HDPJobTracker",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_hbase_masters:
+ generate_daemon("gmond",
+ name = "HDPHBaseMaster",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_resourcemanager:
+ generate_daemon("gmond",
+ name = "HDPResourceManager",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_nodemanager:
+ generate_daemon("gmond",
+ name = "HDPNodeManager",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_historyserver:
+ generate_daemon("gmond",
+ name = "HDPHistoryServer",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_slaves:
+ generate_daemon("gmond",
+ name = "HDPDataNode",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_tasktracker:
+ generate_daemon("gmond",
+ name = "HDPTaskTracker",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_hbase_rs:
+ generate_daemon("gmond",
+ name = "HDPHBaseRegionServer",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_flume:
+ generate_daemon("gmond",
+ name = "HDPFlumeServer",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ if params.has_journalnode:
+ generate_daemon("gmond",
+ name = "HDPJournalNode",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ generate_daemon("gmetad",
+ name = "gmetad",
+ role = "server",
+ owner = "root",
+ group = params.user_group)
+
+ change_permission()
+ server_files()
+ File(path.join(params.ganglia_dir, "gmetad.conf"),
+ owner="root",
+ group=params.user_group
+ )
+
+
+def change_permission():
+ import params
+
+ Directory('/var/lib/ganglia/dwoo',
+ mode=0777,
+ owner=params.gmetad_user,
+ recursive=True
+ )
+
+
+def server_files():
+ import params
+
+ rrd_py_path = params.rrd_py_path
+ Directory(rrd_py_path,
+ recursive=True
+ )
+ rrd_py_file_path = path.join(rrd_py_path, "rrd.py")
+ File(rrd_py_file_path,
+ content=StaticFile("rrd.py"),
+ mode=0755
+ )
+ rrd_file_owner = params.gmetad_user
+ if params.rrdcached_default_base_dir != params.rrdcached_base_dir:
+ Directory(params.rrdcached_base_dir,
+ owner=rrd_file_owner,
+ group=rrd_file_owner,
+ mode=0755,
+ recursive=True
+ )
+ Directory(params.rrdcached_default_base_dir,
+ action = "delete"
+ )
+ Link(params.rrdcached_default_base_dir,
+ to=params.rrdcached_base_dir
+ )
+ elif rrd_file_owner != 'nobody':
+ Directory(params.rrdcached_default_base_dir,
+ owner=rrd_file_owner,
+ group=rrd_file_owner,
+ recursive=True
+ )
+
+
+if __name__ == "__main__":
+ GangliaServer().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server_service.py
new file mode 100644
index 0000000..b93e3f8
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/ganglia_server_service.py
@@ -0,0 +1,27 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import *
+
+
+def server(action=None):# 'start' or 'stop'
+ command = "service hdp-gmetad {action} >> /tmp/gmetad.log 2>&1 ; /bin/ps auwx | /bin/grep [g]metad >> /tmp/gmetad.log 2>&1"
+ Execute(format(command),
+ path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'
+ )
+ MonitorWebserver("restart")
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/params.py
new file mode 100644
index 0000000..601601e
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/params.py
@@ -0,0 +1,80 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import *
+from resource_management.core.system import System
+
+config = Script.get_config()
+
+user_group = config['configurations']['global']["user_group"]
+ganglia_conf_dir = "/etc/ganglia/hdp"
+ganglia_dir = "/etc/ganglia"
+ganglia_runtime_dir = config['configurations']['global']["ganglia_runtime_dir"]
+ganglia_shell_cmds_dir = "/usr/libexec/hdp/ganglia"
+
+gmetad_user = config['configurations']['global']["gmetad_user"]
+gmond_user = config['configurations']['global']["gmond_user"]
+
+webserver_group = "apache"
+rrdcached_default_base_dir = "/var/lib/ganglia/rrds"
+rrdcached_base_dir = config['configurations']['global']["rrdcached_base_dir"]
+
+ganglia_server_host = config["clusterHostInfo"]["ganglia_server_host"][0]
+
+hostname = config["hostname"]
+namenode_host = default("/clusterHostInfo/namenode_host", [])
+jtnode_host = default("/clusterHostInfo/jtnode_host", [])
+rm_host = default("/clusterHostInfo/rm_host", [])
+hs_host = default("/clusterHostInfo/hs_host", [])
+hbase_master_hosts = default("/clusterHostInfo/hbase_master_hosts", [])
+# datanodes are marked as slave_hosts
+slave_hosts = default("/clusterHostInfo/slave_hosts", [])
+tt_hosts = default("/clusterHostInfo/mapred_tt_hosts", [])
+nm_hosts = default("/clusterHostInfo/nm_hosts", [])
+hbase_rs_hosts = default("/clusterHostInfo/hbase_rs_hosts", [])
+flume_hosts = default("/clusterHostInfo/flume_hosts", [])
+jn_hosts = default("/clusterHostInfo/journalnode_hosts", [])
+
+is_namenode_master = hostname in namenode_host
+is_jtnode_master = hostname in jtnode_host
+is_rmnode_master = hostname in rm_host
+is_hsnode_master = hostname in hs_host
+is_hbase_master = hostname in hbase_master_hosts
+is_slave = hostname in slave_hosts
+is_tasktracker = hostname in tt_hosts
+is_nodemanager = hostname in nm_hosts
+is_hbase_rs = hostname in hbase_rs_hosts
+is_flume = hostname in flume_hosts
+is_jn_host = hostname in jn_hosts
+
+has_namenodes = not len(namenode_host) == 0
+has_jobtracker = not len(jtnode_host) == 0
+has_resourcemanager = not len(rm_host) == 0
+has_historyserver = not len(hs_host) == 0
+has_hbase_masters = not len(hbase_master_hosts) == 0
+has_slaves = not len(slave_hosts) == 0
+has_tasktracker = not len(tt_hosts) == 0
+has_nodemanager = not len(nm_hosts) == 0
+has_hbase_rs = not len(hbase_rs_hosts) == 0
+has_flume = not len(flume_hosts) == 0
+has_journalnode = not len(jn_hosts) == 0
+
+if System.get_instance().os_family == "suse":
+ rrd_py_path = '/srv/www/cgi-bin'
+else:
+ rrd_py_path = '/var/www/cgi-bin'
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/status_params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/status_params.py
new file mode 100644
index 0000000..3ccad2f
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/scripts/status_params.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+from resource_management import *
+
+config = Script.get_config()
+
+pid_dir = config['configurations']['global']['ganglia_runtime_dir']
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaClusters.conf.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaClusters.conf.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaClusters.conf.j2
new file mode 100644
index 0000000..f3bb355
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaClusters.conf.j2
@@ -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.
+# */
+
+#########################################################
+### ClusterName GmondMasterHost GmondPort ###
+#########################################################
+
+ HDPJournalNode {{ganglia_server_host}} 8654
+ HDPFlumeServer {{ganglia_server_host}} 8655
+ HDPHBaseRegionServer {{ganglia_server_host}} 8656
+ HDPNodeManager {{ganglia_server_host}} 8657
+ HDPTaskTracker {{ganglia_server_host}} 8658
+ HDPDataNode {{ganglia_server_host}} 8659
+ HDPSlaves {{ganglia_server_host}} 8660
+ HDPNameNode {{ganglia_server_host}} 8661
+ HDPJobTracker {{ganglia_server_host}} 8662
+ HDPHBaseMaster {{ganglia_server_host}} 8663
+ HDPResourceManager {{ganglia_server_host}} 8664
+ HDPHistoryServer {{ganglia_server_host}} 8666
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaEnv.sh.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaEnv.sh.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaEnv.sh.j2
new file mode 100644
index 0000000..1ead550
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaEnv.sh.j2
@@ -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={{gmetad_user}};
+GMOND_USER={{gmond_user}};
+WEBSERVER_GROUP={{webserver_group}};
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaLib.sh.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaLib.sh.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaLib.sh.j2
new file mode 100644
index 0000000..4b5bdd1
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/gangliaLib.sh.j2
@@ -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}`;
+
+GANGLIA_CONF_DIR={{ganglia_conf_dir}};
+GANGLIA_RUNTIME_DIR={{ganglia_runtime_dir}};
+RRDCACHED_BASE_DIR={{rrdcached_base_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
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/configuration/hbase-log4j.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/configuration/hbase-log4j.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/configuration/hbase-log4j.xml
new file mode 100644
index 0000000..2258d73
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/configuration/hbase-log4j.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * 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.
+ */
+-->
+
+<configuration>
+
+ <property>
+ <name>hbase.root.logger</name>
+ <value>INFO,console</value>
+ </property>
+ <property>
+ <name>hbase.security.logger</name>
+ <value>INFO,console</value>
+ </property>
+ <property>
+ <name>hbase.log.dir</name>
+ <value>.</value>
+ </property>
+ <property>
+ <name>hbase.log.file</name>
+ <value>hbase.log</value>
+ </property>
+ <property>
+ <name>log4j.rootLogger</name>
+ <value>${hbase.root.logger}</value>
+ </property>
+ <property>
+ <name>log4j.threshold</name>
+ <value>ALL</value>
+ </property>
+ <property>
+ <name>log4j.appender.DRFA</name>
+ <value>org.apache.log4j.DailyRollingFileAppender</value>
+ </property>
+ <property>
+ <name>log4j.appender.DRFA.File</name>
+ <value>${hbase.log.dir}/${hbase.log.file}</value>
+ </property>
+ <property>
+ <name>log4j.appender.DRFA.DatePattern</name>
+ <value>.yyyy-MM-dd</value>
+ </property>
+ <property>
+ <name>log4j.appender.DRFA.layout</name>
+ <value>org.apache.log4j.PatternLayout</value>
+ </property>
+ <property>
+ <name>log4j.appender.DRFA.layout.ConversionPattern</name>
+ <value>%d{ISO8601} %-5p [%t] %c{2}: %m%n</value>
+ </property>
+ <property>
+ <name>hbase.log.maxfilesize</name>
+ <value>256MB</value>
+ </property>
+ <property>
+ <name>hbase.log.maxbackupindex</name>
+ <value>20</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA</name>
+ <value>org.apache.log4j.RollingFileAppender</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA.File</name>
+ <value>${hbase.log.dir}/${hbase.log.file}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA.MaxFileSize</name>
+ <value>${hbase.log.maxfilesize}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA.MaxBackupIndex</name>
+ <value>${hbase.log.maxbackupindex}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA.layout</name>
+ <value>org.apache.log4j.PatternLayout</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFA.layout.ConversionPattern</name>
+ <value>%d{ISO8601} %-5p [%t] %c{2}: %m%n</value>
+ </property>
+ <property>
+ <name>hbase.security.log.file</name>
+ <value>SecurityAuth.audit</value>
+ </property>
+ <property>
+ <name>hbase.security.log.maxfilesize</name>
+ <value>256MB</value>
+ </property>
+ <property>
+ <name>hbase.security.log.maxbackupindex</name>
+ <value>20</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS</name>
+ <value>org.apache.log4j.RollingFileAppender</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS.File</name>
+ <value>${hbase.log.dir}/${hbase.security.log.file}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS.MaxFileSize</name>
+ <value>${hbase.security.log.maxfilesize}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS.MaxBackupIndex</name>
+ <value>${hbase.security.log.maxbackupindex}</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS.layout</name>
+ <value>org.apache.log4j.PatternLayout</value>
+ </property>
+ <property>
+ <name>log4j.appender.RFAS.layout.ConversionPattern</name>
+ <value>%d{ISO8601} %p %c: %m%n</value>
+ </property>
+ <property>
+ <name>log4j.category.SecurityLogger</name>
+ <value>${hbase.security.logger}</value>
+ </property>
+ <property>
+ <name>log4j.additivity.SecurityLogger</name>
+ <value>false</value>
+ </property>
+ <property>
+ <name>log4j.appender.NullAppender</name>
+ <value>org.apache.log4j.varia.NullAppender</value>
+ </property>
+ <property>
+ <name>log4j.appender.console</name>
+ <value>org.apache.log4j.ConsoleAppender</value>
+ </property>
+ <property>
+ <name>log4j.appender.console.target</name>
+ <value>System.err</value>
+ </property>
+ <property>
+ <name>log4j.appender.console.layout</name>
+ <value>org.apache.log4j.PatternLayout</value>
+ </property>
+ <property>
+ <name>log4j.appender.console.layout.ConversionPattern</name>
+ <value>%d{ISO8601} %-5p [%t] %c{2}: %m%n</value>
+ </property>
+ <property>
+ <name>log4j.logger.org.apache.zookeeper</name>
+ <value>INFO</value>
+ </property>
+ <property>
+ <name>log4j.logger.org.apache.hadoop.hbase</name>
+ <value>DEBUG</value>
+ </property>
+ <property>
+ <name>log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil</name>
+ <value>INFO</value>
+ </property>
+ <property>
+ <name>log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher</name>
+ <value>INFO</value>
+ </property>
+
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml
index afe527d..c16b160 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml
@@ -16,29 +16,79 @@
limitations under the License.
-->
<metainfo>
- <user>mapred</user>
- <comment>Non-relational distributed database and centralized service for configuration management & synchronization</comment>
- <version>0.96.1.2.0.6.1</version>
-
- <components>
+ <schemaVersion>2.0</schemaVersion>
+ <services>
+ <service>
+ <name>HBASE</name>
+ <comment>Non-relational distributed database and centralized service for configuration management &
+ synchronization
+ </comment>
+ <version>0.96.0.2.1.1</version>
+ <components>
<component>
- <name>HBASE_MASTER</name>
- <category>MASTER</category>
+ <name>HBASE_MASTER</name>
+ <category>MASTER</category>
+ <commandScript>
+ <script>scripts/hbase_master.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>600</timeout>
+ </commandScript>
+ <customCommands>
+ <customCommand>
+ <name>DECOMMISSION</name>
+ <commandScript>
+ <script>scripts/hbase_master.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>600</timeout>
+ </commandScript>
+ </customCommand>
+ </customCommands>
</component>
<component>
- <name>HBASE_REGIONSERVER</name>
- <category>SLAVE</category>
+ <name>HBASE_REGIONSERVER</name>
+ <category>SLAVE</category>
+ <commandScript>
+ <script>scripts/hbase_regionserver.py</script>
+ <scriptType>PYTHON</scriptType>
+ </commandScript>
</component>
<component>
- <name>HBASE_CLIENT</name>
- <category>CLIENT</category>
+ <name>HBASE_CLIENT</name>
+ <category>CLIENT</category>
+ <commandScript>
+ <script>scripts/hbase_client.py</script>
+ <scriptType>PYTHON</scriptType>
+ </commandScript>
</component>
- </components>
- <configuration-dependencies>
- <config-type>global</config-type>
- <config-type>hbase-site</config-type>
- <config-type>hbase-policy</config-type>
- </configuration-dependencies>
+ </components>
+
+ <osSpecifics>
+ <osSpecific>
+ <osType>any</osType>
+ <packages>
+ <package>
+ <type>rpm</type>
+ <name>hbase</name>
+ </package>
+ </packages>
+ </osSpecific>
+ </osSpecifics>
+
+ <commandScript>
+ <script>scripts/service_check.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>300</timeout>
+ </commandScript>
+
+ <configuration-dependencies>
+ <config-type>global</config-type>
+ <config-type>hbase-policy</config-type>
+ <config-type>hbase-site</config-type>
+ <config-type>hbase-log4j</config-type>
+ </configuration-dependencies>
+
+ </service>
+ </services>
</metainfo>
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/files/hbaseSmokeVerify.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/files/hbaseSmokeVerify.sh b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/files/hbaseSmokeVerify.sh
new file mode 100644
index 0000000..39fe6e5
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/files/hbaseSmokeVerify.sh
@@ -0,0 +1,32 @@
+#
+#
+# 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.
+#
+#
+conf_dir=$1
+data=$2
+echo "scan 'ambarismoketest'" | hbase --config $conf_dir shell > /tmp/hbase_chk_verify
+cat /tmp/hbase_chk_verify
+echo "Looking for $data"
+grep -q $data /tmp/hbase_chk_verify
+if [ "$?" -ne 0 ]
+then
+ exit 1
+fi
+
+grep -q '1 row(s)' /tmp/hbase_chk_verify
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/43f14b34/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/scripts/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/scripts/__init__.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/scripts/__init__.py
new file mode 100644
index 0000000..5561e10
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/package/scripts/__init__.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""