diff --git a/Dockerfile b/Dockerfile index 1c8d603..6114da5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,8 @@ COPY --chown=telegraf:0 conf/telegraf.conf /etc/telegraf/telegraf.conf COPY --chown=telegraf:0 conf/nuodb.conf /etc/telegraf/telegraf.d/static/nuodb.conf COPY --chown=telegraf:0 conf/outputs.conf /etc/telegraf/telegraf.d/dynamic/outputs.conf +COPY --chown=telegraf:0 bin/nuocd /usr/local/bin/nuocd + USER 1000:0 CMD ["telegraf", "--config", "/etc/telegraf/telegraf.conf", "--config-directory", "/etc/telegraf/telegraf.d"] diff --git a/README.md b/README.md index cf54637..3ce43f4 100644 --- a/README.md +++ b/README.md @@ -221,10 +221,12 @@ sudo cp -r nuocd /opt/ The `conf/nuodb.conf` file in this repository configures all four input plugins for NuoDB running on localhost as described in the section above. The `conf/outputs.conf` file configures an output plugin to a InfluxDB instance defined by the `$INFLUXURL` environment variable. +The `bin/nuocd` file is a convenience wrapper for python. Replace the `` placeholder in the `INFLUXURL` line below with the hostname of the machine running the InfluxDB instance, and then run the commands. ``` sudo cp conf/nuodb.conf /etc/telegraf/telegraf.d sudo cp conf/outputs.conf /etc/telegraf/telegraf.d +sudo cp bin/nuocd /usr/local/bin/nuocd sudo chown -R telegraf.telegraf /etc/telegraf cat </etc/default/telegraf INFLUXURL=http://:8086 diff --git a/bin/nuocd b/bin/nuocd new file mode 100755 index 0000000..93662b9 --- /dev/null +++ b/bin/nuocd @@ -0,0 +1,16 @@ +#!/bin/sh +# +# (C) Copyright NuoDB, Inc. 2020-2021 All Rights Reserved + +# Unfortunately, ksh93 defines builtin aliases even when run non-interactively. +unalias -a + +die () { echo "$*"; exit 1; } + +_python=${PYTHON} +if test -z "$_python"; then + _python=$(command -v python2.7) || _python=$(command -v python2) || _python=$(command -v python) \ + || die "Python must be installed" +fi + +exec "$_python" "$@" diff --git a/conf/nuodb.conf b/conf/nuodb.conf index 114accd..5ea571c 100644 --- a/conf/nuodb.conf +++ b/conf/nuodb.conf @@ -3,7 +3,7 @@ # the helm chart. probably want to put into different files. [[inputs.execd]] - command = [ "python", "/opt/nuocd/nuodb_adminquery.py", "-i", "0", "metrics" ] + command = [ "nuocd", "/opt/nuocd/nuodb_adminquery.py", "-i", "0", "metrics" ] signal = "none" restart_delay = "10s" data_format = "influx" @@ -11,7 +11,7 @@ db_tag = "nuodb" [[inputs.execd]] - command = [ "python", "/opt/nuocd/nuodb_adminquery.py", "-i", "30", "msgtrace" ] + command = [ "nuocd", "/opt/nuocd/nuodb_adminquery.py", "-i", "30", "msgtrace" ] signal = "none" restart_delay = "10s" @@ -29,7 +29,7 @@ db_tag = "nuodb_internal" [[inputs.execd]] - command = [ "python", "/opt/nuocd/nuodb_adminquery.py", "-i", "30", "synctrace" ] + command = [ "nuocd", "/opt/nuocd/nuodb_adminquery.py", "-i", "30", "synctrace" ] signal = "none" restart_delay = "10s" @@ -49,7 +49,7 @@ db_tag = "nuodb_internal" [[inputs.execd]] - command = [ "python", "/opt/nuocd/nuodb_threads.py" ] + command = [ "nuocd", "/opt/nuocd/nuodb_threads.py" ] signal = "none" restart_delay = "10s" diff --git a/conf/telegraf.conf b/conf/telegraf.conf index c27fe50..657fd4c 100644 --- a/conf/telegraf.conf +++ b/conf/telegraf.conf @@ -17,7 +17,7 @@ [[inputs.execd]] # no input, setups webserver on 0.0.0.0:5000/reload to reload configuration file via url. - command = [ "python", "/opt/nuocd/telegraf_reload.py" ] + command = [ "nuocd", "/opt/nuocd/telegraf_reload.py" ] signal = "none" restart_delay = "10s" diff --git a/tests/ci/install_nuocd.sh b/tests/ci/install_nuocd.sh index bc09304..71b0bf5 100755 --- a/tests/ci/install_nuocd.sh +++ b/tests/ci/install_nuocd.sh @@ -9,6 +9,7 @@ pip install -r requirements.txt sudo cp conf/nuodb.conf /etc/telegraf/telegraf.d sudo cp conf/outputs.conf /etc/telegraf/telegraf.d +sudo cp bin/nuocd /usr/local/bin/nuocd sudo systemctl daemon-reload sudo systemctl stop telegraf