diff --git a/src/commandline.sh b/src/commandline.sh index 924cf94..66ae28a 100644 --- a/src/commandline.sh +++ b/src/commandline.sh @@ -200,6 +200,6 @@ parse_commandline_args() { if [ "$WATCHDOGMODE" = "true" ]; then startup_version startup_debug - watchdog_check + watchdog_run fi } diff --git a/src/logic_watchdog.sh b/src/logic_watchdog.sh index de36fe0..4e74be7 100644 --- a/src/logic_watchdog.sh +++ b/src/logic_watchdog.sh @@ -160,6 +160,15 @@ get_watchdog_status() { } +watchdog_run() { + local host_hash + host_hash=$(printf '%s' "$(hostname)" | md5sum | awk '{print $1}' | cut -c1-8 | xargs printf '%d' 16 16) + local offset=$(( host_hash % 300 )) + echo "Watchdog delay: sleeping ${offset}s (host-based offset)" + sleep "$offset" + watchdog_check +} + watchdog_check() { echo "---------------------------" echo " Nightscout Watchdog mode"