Skip to content

gantree-io/gantree-node-watchdog

Repository files navigation

GitHub Discord gantree.io status Website OSS Lifecycle

Gantree Node Watchdog

Instance monitoring client for Gantree

Quick Start

curl -o- https://raw.githubusercontent.com/gantree-io/gantree-node-watchdog/master/quick-install.sh | bash && cd gantree-node-watchdog-v*.*.*-linux && ./bin/gantree_node_watchdog

Releases

Stand-alone binaries can be found in releases.

GitHub release (latest SemVer including pre-releases)

Configuration

GNW can be configured using a variety of methods.

In order of greatest precedence, these are:

  • Environment variables
  • Configuration file
  • User prompts
  • Defaults

The following values must be configured for every installation

NAME ENVIRONMENT VARIABLE CONFIGURATION FILE
API Key GANTREE_NODE_WATCHDOG_API_KEY api_key
Project ID GANTREE_NODE_WATCHDOG_PROJECT_ID project_id
Client ID GANTREE_NODE_WATCHDOG_CLIENT_ID client_id

Optionally, the following may also be configured

NAME ENVIRONMENT VARIABLE CONFIGURATION FILE
PCKRC GANTREE_NODE_WATCHDOG_PCKRC pckrc
IP Address GANTREE_NODE_WATCHDOG_IP_ADDRESS ip_address
Proxy Host GANTREE_NODE_WATCHDOG_PROXY_HOST proxy_host
Metrics Host GANTREE_NODE_WATCHDOG_METRICS_HOST metrics_host
Node ID GANTREE_NODE_WATCHDOG_NODE_ID node_id
Node Secret GANTREE_NODE_WATCHDOG_NODE_SECRET node_secret
Prompt Missing GANTREE_NODE_WATCHDOG_PROMPT_MISSING prompt_missing

If any required values have not been configured, GNW will prompt you to enter them in your terminal.

If you would prefer to raise an exception instead, this behaviour can be disabled by setting prompt missing to false.

Any prompted values will be stored in the configuration file.

Simple Usage

To start GNW, run the following in your terminal

./gantree-node-watchdog

If GNW has not yet been configured, you will be prompted to enter any required values.

To stop GNW

  • Ensure the terminal running GNW is focused
  • Press Ctrl+C

Systemd

Installation

Create the file gnw.service under /etc/systemd/system/ with the following contents:

# Contents of /etc/systemd/system/gnw.service

[Unit]
Description=Gantree Node Watchdog
After=network.target

[Service]
WorkingDirectory=/var/lib/gantree/gnw
Type=simple
Restart=always
ExecStart=/usr/local/bin/gantree_node_watchdog

[Install]
WantedBy=multi-user.target

Now copy the gantree_node_watchdog binary to /usr/local/bin/

cp [/path/to/gnw/binary] /usr/local/bin

Finally configure all required options by either exporting the associated environment variables or specifying values in ~/.gnw_config.json.

Usage

To start GNW

systemctl --user start gnw

To view logs

journalctl --user -f -u gnw

To stop GNW

systemctl --user stop gnw

Development

Run the following from the root directory of the cloned repository (gantree-node-watchdog) to automatically restart GNW when changes occur in watched folders.

This requires PM2 to be installed globally via NPM.

pipenv run dev

To view logs

pm2 log gnw

Please note that due to the way PM2 captures stdout/stderr

  • Messages will appear incorrectly formatted
  • Coloured output is not possible

To stop GNW

pm2 del gnw

Building

Requirements

GitHub Pipenv locked Python version

Package Version Notes
pipenv latest -
pyenv latest only if required python version not installed
make latest -

Steps

source configure.sh
pipenv install --dev # if prompted to install python version, accept
pipenv shell
make

Notes

Ipify Service

Gantree Node Watchdog uses ipify to get your machine's public ip address automatically.

Although we have a legitimate use-case for the ipify service, some malicious actors use the same service for command-and-control botnets.

Any potential warnings related to GNW contacting api.ipify.org are false-positives and, if required, are safe to add to your firewall's allow list.