summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Hainke <vincent@systemli.org>2022-01-13 09:34:44 +0100
committerNick Hainke <vincent@systemli.org>2022-01-13 10:10:03 +0100
commit61cd00cb8ebfa8657a2ee455c65ed87979e0d050 (patch)
tree8ca91d22535d59ffde33da506db720d472702088
parent440e7af33922919e44972f0eb45cd237d3382267 (diff)
naywatch: introduce kick-count
Check multiple rounds if neighbors are available before kicking. This should reduce unneeded reboots. Signed-off-by: Nick Hainke <vincent@systemli.org> (cherry picked from commit 24285ce4fcd56aa806bdbe9ac16cbfed0a81d2f8)
-rw-r--r--naywatch/files/naywatch.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/naywatch/files/naywatch.sh b/naywatch/files/naywatch.sh
index e6d2fb7..3627464 100644
--- a/naywatch/files/naywatch.sh
+++ b/naywatch/files/naywatch.sh
@@ -14,6 +14,8 @@ shift
INTERFACES="$*"
ACTIVE=0
+NO_NEIGHBORS_COUNT=0
+MIN_KICK=5
log() {
local msg="$1"
@@ -67,6 +69,8 @@ reboot_now() {
no_neighbors() {
log "No Neighbors Available!"
+ NO_NEIGHBORS_COUNT=$(($NO_NEIGHBORS_COUNT+1))
+
if [ $ACTIVE -eq 0 ]; then
return 0
fi
@@ -76,7 +80,7 @@ no_neighbors() {
write_logs
fi
- if [ $USE_WATCHDOG -eq 0 ]; then
+ if [ $USE_WATCHDOG -eq 0 ] && [ $NO_NEIGHBORS_COUNT -gt $MIN_KICK ]; then
reboot_now
fi
}
@@ -85,6 +89,7 @@ log "Naywatch Started!"
neighbors() {
ACTIVE=1
+ NO_NEIGHBORS_COUNT=0
if [ $USE_WATCHDOG -eq 1 ]; then
echo 1 >&3
fi