Last active
August 29, 2015 14:21
-
-
Save voxxit/52f71fc81263cb3a81bf to your computer and use it in GitHub Desktop.
Reworked install script for the Python-based Datadog agent — curl -L http://git.io/vTyed | sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment