Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuoCD wrapper for python #21

Merged
merged 11 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<hostinflux>` 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 <<EOF >/etc/default/telegraf
INFLUXURL=http://<hostinflux>:8086
Expand Down
16 changes: 16 additions & 0 deletions bin/nuocd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should call this something else, since it actually is not specific to nuocd, e.g. python-wrapper.

#
# (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" "$@"
8 changes: 4 additions & 4 deletions conf/nuodb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# 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"
[inputs.execd.tags]
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"

Expand All @@ -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"

Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion conf/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions tests/ci/install_nuocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down