chukwa-config.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # included in all the hadoop scripts with source command
  16. # should not be executable directly
  17. # also should not be passed any arguments, since we need original $*
  18. # resolve links - $0 may be a softlink
  19. this="$0"
  20. while [ -h "$this" ]; do
  21. ls=`ls -ld "$this"`
  22. link=`expr "$ls" : '.*-> \(.*\)$'`
  23. if expr "$link" : '.*/.*' > /dev/null; then
  24. this="$link"
  25. else
  26. this=`dirname "$this"`/"$link"
  27. fi
  28. done
  29. # convert relative path to absolute path
  30. bin=`dirname "$this"`
  31. script=`basename "$this"`
  32. bin=`cd "$bin"; pwd`
  33. this="$bin/$script"
  34. # the root of the Chukwa installation
  35. export CHUKWA_HOME=`dirname "$this"`/..
  36. #check to see if the conf dir is given as an optional argument
  37. if [ $# -gt 1 ]
  38. then
  39. if [ "--config" = "$1" ]
  40. then
  41. shift
  42. confdir=$1
  43. shift
  44. CHUKWA_CONF_DIR=$confdir
  45. fi
  46. fi
  47. #check to see it is specified whether to use the slaves or the
  48. # masters file
  49. if [ $# -gt 1 ]
  50. then
  51. if [ "--hosts" = "$1" ]
  52. then
  53. shift
  54. slavesfile=$1
  55. shift
  56. export CHUKWA_SLAVES="${CHUKWA_CONF_DIR}/$slavesfile"
  57. fi
  58. fi
  59. #check to see if the conf dir is given as an optional argument
  60. if [ $# -gt 1 ]
  61. then
  62. if [ "--watchdog" = "$1" ]
  63. then
  64. shift
  65. WATCHDOG="true"
  66. fi
  67. fi
  68. if [ -z ${CHUKWA_LOG_DIR} ]; then
  69. export CHUKWA_LOG_DIR="$CHUKWA_HOME/logs"
  70. fi
  71. if [ -z ${CHUKWA_PID_DIR} ]; then
  72. export CHUKWA_PID_DIR="${CHUKWA_HOME}/var/run"
  73. fi
  74. CHUKWA_VERSION=`cat ${CHUKWA_HOME}/bin/VERSION`
  75. # Allow alternate conf dir location.
  76. if [ -z "$CHUKWA_CONF_DIR" ]; then
  77. CHUKWA_CONF_DIR="${CHUKWA_CONF_DIR:-$CHUKWA_HOME/conf}"
  78. export CHUKWA_CONF_DIR=${CHUKWA_HOME}/conf
  79. fi
  80. if [ -f "${CHUKWA_CONF_DIR}/chukwa-env.sh" ]; then
  81. . "${CHUKWA_CONF_DIR}/chukwa-env.sh"
  82. fi
  83. export DATACONFIG=${CHUKWA_CONF_DIR}/mdl.xml
  84. COMMON=`ls ${CHUKWA_HOME}/lib/*.jar ${CHUKWA_HOME}/hadoopjars/commons*.jar`
  85. export COMMON=`echo ${COMMON} | sed 'y/ /:/'`
  86. export CHUKWA_CORE=${CHUKWA_HOME}/chukwa-core-${CHUKWA_VERSION}.jar
  87. export CHUKWA_AGENT=${CHUKWA_HOME}/chukwa-agent-${CHUKWA_VERSION}.jar
  88. export CURRENT_DATE=`date +%Y%m%d%H%M`
  89. if [ -z ${HADOOP_JAR} ]; then
  90. if [ -z ${HADOOP_HOME} ]; then
  91. export HADOOP_HOME=../../..
  92. fi
  93. if [ -d ${HADOOP_HOME} ]; then
  94. export HADOOP_JAR=`ls ${HADOOP_HOME}/hadoop-*-core.jar`
  95. if [ -z ${HADOOP_JAR} ]; then
  96. echo "Please make sure hadoop-*-core.jar exists in ${HADOOP_HOME}"
  97. exit -1
  98. fi
  99. else
  100. if [ -d ${CHUKWA_HOME}/hadoopjars ]; then
  101. echo "WARNING: neither HADOOP_HOME nor HADOOP_JAR is set we we are reverting to defaults in $CHUKWA_HOME/hadoopjars dir"
  102. export HADOOP_JAR=`ls ${CHUKWA_HOME}/hadoopjars/hadoop-*-core.jar`
  103. else
  104. echo "Please make sure hadoop-*-core.jar exists in ${CHUKWA_HOME}/hadoopjars"
  105. exit -1
  106. fi
  107. fi
  108. fi
  109. if [ -z "$JAVA_HOME" ] ; then
  110. echo ERROR! You forgot to set JAVA_HOME in conf/chukwa-env.sh
  111. fi
  112. export JPS="ps ax"