Skip to content

Commit

Permalink
Merge pull request #170 from jkossis/add-slave-config
Browse files Browse the repository at this point in the history
Add configuration for running smokeping in slave mode
  • Loading branch information
thespad committed Mar 22, 2024
2 parents e7be439 + d88cc5c commit da61e11
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ param_ports:
param_usage_include_env: true
param_env_vars:
- { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London"}
opt_param_usage_include_env: true
opt_param_env_vars:
- { env_var: "MASTER_URL", env_value: "http://<master-host-ip>:80/smokeping/", desc: "Specify the master url to connect to. Used when in slave mode."}
- { env_var: "SHARED_SECRET", env_value: "password", desc: "Specify the master shared secret for this host. Used when in slave mode."}
- { env_var: "CACHE_DIR", env_value: "/tmp", desc: "Specify the cache directory for this host. Used when in slave mode."}

# application setup block
app_setup_block_enabled: true
Expand All @@ -34,9 +39,11 @@ app_setup_block: |
* To reload the configuration without restarting the container, run `docker exec smokeping pkill -f -HUP '/usr/bin/perl /usr/s?bin/smokeping(_cgi)?'`, where `smokeping` is the container ID.
* To restart the container, run `docker restart smokeping`, where `smokeping` is the container ID.
* Note that the default `Targets` file includes items that may or may not work. These are simply to provide examples of configuration.
* Slave setup: modify the `Targets`, `Slaves`, and `smokeping_secrets` files on the master host, per [the documentation](https://manpages.ubuntu.com/manpages/trusty/en/man7/smokeping_master_slave.7.html).
# changelog
changelogs:
- { date: "22.03.24:", desc: "Adding ability to run as a slave."}
- { date: "23.12.23:", desc: "Rebase to Alpine 3.19."}
- { date: "29.11.23:", desc: "Bump tcpping to 1.8." }
- { date: "21.11.23:", desc: "Add support for IRTT Probes." }
Expand Down
3 changes: 3 additions & 0 deletions root/defaults/smokeping_secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
host1:mysecret
host2:yoursecret
boomer:lkasdf93uhhfdfddf
8 changes: 8 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/init-smokeping-config/run
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ if [[ ! -L /etc/apache2/httpd.conf ]]; then
ln -sf /config/httpd.conf /etc/apache2/httpd.conf
fi

if [[ ! -e /config/smokeping_secrets ]]; then
cp /defaults/smokeping_secrets /config/smokeping_secrets
fi

if [[ ! -L /etc/smokeping/smokeping_secrets ]]; then
ln -sf /config/smokeping_secrets /etc/smokeping/smokeping_secrets
fi

if [[ -e /config/ssmtp.conf ]]; then
cp /config/ssmtp.conf /etc/ssmtp/ssmtp.conf
fi
Expand Down
10 changes: 8 additions & 2 deletions root/etc/s6-overlay/s6-rc.d/svc-smokeping/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

exec \
s6-setuidgid abc /usr/sbin/smokeping --config="/etc/smokeping/config" --nodaemon
if [ -n "${MASTER_URL}" ] && [ -n "${SHARED_SECRET}" ] && [ -n "${CACHE_DIR}" ]; then
install -g abc -o abc -m 400 -D <(echo $SHARED_SECRET) /var/smokeping/secret.txt
exec \
s6-setuidgid abc /usr/sbin/smokeping --master-url="${MASTER_URL}" --cache-dir="${CACHE_DIR}" --shared-secret="/var/smokeping/secret.txt" --nodaemon
else
exec \
s6-setuidgid abc /usr/sbin/smokeping --config="/etc/smokeping/config" --nodaemon
fi

3 comments on commit da61e11

@r2ixuz
Copy link

@r2ixuz r2ixuz commented on da61e11 Mar 23, 2024

Choose a reason for hiding this comment

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

smokeping_secrets is not allowed to be world readable/writeable. Otherwise Smokeping does not work.

Needed manually todo to make Smokeping working again:

chmod o-rx smokeping_secrets

@MattKobayashi
Copy link

@MattKobayashi MattKobayashi commented on da61e11 Mar 23, 2024

Choose a reason for hiding this comment

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

Confirmed, this change broke my existing Smokeping instances. The below command fixed it for me, adjust for your use case depending on container name and/or non-Compose containers:

docker compose exec smokeping chmod o-rx /config/smokeping_secrets \
&& docker compose restart smokeping

@thespad
Copy link
Member Author

Choose a reason for hiding this comment

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

Guys, for future reference please open an issue and link to the commit/PR rather than commenting on the commit - it was pure chance I saw this in our Discord github feed, otherwise it probably would have sat here unnoticed for months.

Please sign in to comment.