Updated Branches: refs/heads/trunk ce40cfc7b -> b34951074
http://git-wip-us.apache.org/repos/asf/ambari/blob/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_monitor_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_monitor_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/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._/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/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server.py new file mode 100644 index 0000000..de2c8cc --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server.py @@ -0,0 +1,143 @@ +""" +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.config(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 config(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_histroryserver: + generate_daemon("gmond", + name = "HDPHistoryServer", + role = "server", + owner = "root", + group = params.user_group) + generate_daemon("gmond", + name = "HDPSlaves", + role = "server", + owner = "root", + group = params.user_group) + generate_daemon("gmond", + 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 + ) + 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 + ) + + +if __name__ == "__main__": + GangliaServer().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server_service.py new file mode 100644 index 0000000..42c98ff --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/ganglia_server_service.py @@ -0,0 +1,28 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +from resource_management import * +from resource_management.libraries.resources.monitor_webserver import MonitorWebserver + + +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/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/params.py new file mode 100644 index 0000000..96ef072 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/scripts/params.py @@ -0,0 +1,64 @@ +""" +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 = config['configurations']['global']["ganglia_conf_dir"] +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", []) +slave_hosts = default("/clusterHostInfo/slave_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 + +has_namenodes = not len(namenode_host) == 0 +has_jobtracker = not len(jtnode_host) == 0 +has_resourcemanager = not len(rm_host) == 0 +has_histroryserver = not len(hs_host) == 0 +has_hbase_masters = not len(hbase_master_hosts) == 0 +has_slaves = not len(slave_hosts) == 0 + +if System.get_instance().platform == "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/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaClusters.conf.j2 ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaClusters.conf.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaClusters.conf.j2 new file mode 100644 index 0000000..f9e708a --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaClusters.conf.j2 @@ -0,0 +1,28 @@ +#/* +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +######################################################### +### ClusterName GmondMasterHost GmondPort ### +######################################################### + + 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/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaEnv.sh.j2 ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaEnv.sh.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0._/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._/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/b3495107/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaLib.sh.j2 ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/templates/gangliaLib.sh.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0._/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._/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 +}
