#!/bin/bash set -x # Root user required if [ "$(id -u)" != "0" ]; then echo "Sorry, you must be root to install dd-agent" && exit 1 fi # Python and sysstat are required if ! command -v python &>/dev/null; then echo "Python not installed" && exit 1; fi if ! command -v iostat &>/dev/null; then echo "sysstat not installed" && exit 1; fi # Python must be between 2.6.x and 3.x.x if ! python -c "import sys; ver = sys.version_info; e = 0 if ver[0] == 2 and ver[1] > 5 else 66; sys.exit(e)"; then echo "Python version must be between 2.6.x and 3.x.x" && exit 1 fi # Command used to grab source files get() { if command -v curl &>/dev/null; then wget --no-check-certificate -q -O- $1 else curl -kfsSL $1 fi } DD_USER=${DD_USER:-datadog} DD_BASEDIR=${DD_BASEDIR:-/opt/local/dd-agent} DD_VERSION=${DD_VERSION:-5.3.0} # Create datadog user if it does not exist if ! id -u ${DD_USER} &>/dev/null; then useradd -d ${DD_BASEDIR} -n -s /sbin/nologin ${DD_USER} fi # Base install structure install -d -o ${DD_USER} ${DD_BASEDIR}/{agent,bin,logs,run,supervisord/logs} ln -nfs ${DD_BASEDIR}/supervisord/logs ${DD_BASEDIR}/logs/supervisord # upgrade pip pip install --upgrade pip pushd ${DD_BASEDIR} # Install & activate virtualenv get https://raw.github.com/pypa/virtualenv/1.11.6/virtualenv.py | python - venv . venv/bin/activate pip install --upgrade pip pip install supervisor==3.0b2 # Install dd-agent & the Python source requirements get https://github.com/Datadog/dd-agent/tarball/${DD_VERSION} | tar -xz -C agent --strip-components 1 pip install -r agent/source-requirements.txt pip install -r agent/source-optional-requirements.txt cp agent/packaging/datadog-agent/source/{agent,info} bin/ cp agent/packaging/datadog-agent/source/supervisord.conf supervisord/supervisord.conf cp agent/datadog.conf.example datadog.conf chown -R ${DD_USER}: . chmod +x bin/{agent,info} popd