Skip to content

Commit

Permalink
ci(launch-all): run exporters if either is on PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgomesdev committed Dec 23, 2023
1 parent fcf0b9a commit 7b075fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 2 additions & 4 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ You can run it every midnight or so, by adding the following line on: `crontab -

Launches everything, it's meant to be run at reboot.

It also launches prometheus _exporters_, namely [node_exporter](https://github.com/prometheus/node_exporter) and [process-exporter](https://github.com/ncabatoff/process-exporter).
It also launches prometheus _exporters_ (in case either is present in PATH), namely [node_exporter](https://github.com/prometheus/node_exporter) and [process-exporter](https://github.com/ncabatoff/process-exporter).

These aren't run if node_exporter is not found in PATH. Both must be in the home directory or anywhere on PATH.

To set them up, just download their binaries and move them to `/usr/bin`.eee
To set them up, just download their binaries and move them to somewhere on PATH such as: `/usr/bin`.

## Grafana stack

Expand Down
10 changes: 2 additions & 8 deletions server/scripts/launch-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ printf "$START* Running at $(date)$RESET\n"

# Start node_exporter

RUSTY_PATH=$(pwd)
NODE_EXPORTER_PATH=${NODE_EXPORTER_PATH:-../node_exporter}

GRAFANA_COMPOSE_OVERRIDE=${GRAFANA_COMPOSE_OVERRIDE:-base}

if [ -f "$NODE_EXPORTER_PATH"/node_exporter ]; then
(cd "$NODE_EXPORTER_PATH" && "$RUSTY_PATH"/server/scripts/run-exporters.sh)
else
echo "${WARNING}Warning: node_exporter wasn't found in $(pwd)/$NODE_EXPORTER_PATH. Not running any exporters.$RESET"
fi
echo
server/scripts/run-exporters.sh

# Start Grafana stack

Expand Down
14 changes: 12 additions & 2 deletions server/scripts/run-exporters.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#!/usr/bin/env bash

SECTION=$(tput setaf 5)
WARNING=$(tput setaf 3)
RESET=$(tput sgr0)

LOG_DIRECTORY="/var/log/rusty-controller/prometheus-exporters"
mkdir -p "$LOG_DIRECTORY"

if ! which node_exporter || which process-exporter; then
printf "${WARNING}No exporters found. $RESET"
exit 0
fi

printf "${SECTION}* Launching Prometheus exporters...$RESET\n"

tmux kill-session -t "Prometheus Exporters" 2>/dev/null && echo "Killed existing Prometheus Exporters tmux session"

tmux new-session -d -s "Prometheus Exporters"

tmux new-window -t "Prometheus Exporters" -n "node_exporter" -c "$(pwd)" "./node_exporter 2>&1 | tee $LOG_DIRECTORY/node_exporter.log"
tmux new-window -t "Prometheus Exporters" -n "node_exporter" -c "$(pwd)" "node_exporter 2>&1 | tee $LOG_DIRECTORY/node_exporter.log"
echo "Started new tmux session for node_exporter"

tmux new-window -t "Prometheus Exporters" -n "process-exporter" -c "$(pwd)" "process-exporter 2>&1 | tee $LOG_DIRECTORY/process-exporter.log"
echo "Started new tmux session for process-exporter"

0 comments on commit 7b075fe

Please sign in to comment.