diff --git a/check_and_reboot_state.json b/check_and_reboot_state.json index 3d2cdaa..d713ae4 100644 --- a/check_and_reboot_state.json +++ b/check_and_reboot_state.json @@ -1 +1 @@ -{"last_reboot_datetime":"2026-01-31T12:56:40.834","consecutive_fails":0} \ No newline at end of file +{"last_reboot_datetime":"2026-03-20T10:49:28.411","consecutive_fails":0} \ No newline at end of file diff --git a/check_router_reboot.jl b/check_router_reboot.jl index 166a835..5099c0b 100644 --- a/check_router_reboot.jl +++ b/check_router_reboot.jl @@ -253,30 +253,15 @@ function perform_check!(st::State) if in_cooldown # During cooldown, track failures but don't trigger reboot yet if success + broadcast_msg("Broadcasting from file: $thisFilePath") logmsg("$ROUTER_IP is reachable during cooldown. Router is back online! Resetting state.") st.consecutive_fails = 0 save_state(st, StateFilePath) else st.consecutive_fails += 1 - + broadcast_msg("Broadcasting from file: $thisFilePath") logmsg("$ROUTER_IP is unreachable during cooldown. Consecutive fails: $(st.consecutive_fails)/$FAILS_TO_REBOOT.") save_state(st, StateFilePath) - - # Check if we've reached threshold by now - if st.consecutive_fails >= FAILS_TO_REBOOT - logmsg("Cooldown has expired and router is still unreachable. Triggering reboot.") - ok = do_reboot() - if ok - thisFilePath = @__FILE__ - broadcast_msg("Broadcasting from file: $thisFilePath") - logmsg("Reboot executed (or simulated). Resetting failure counter.") - st.consecutive_fails = 0 - st.last_reboot_datetime = Dates.now() - save_state(st, StateFilePath) - else - logmsg("Reboot attempt failed; will retry after next interval.") - end - end end return end @@ -293,6 +278,7 @@ function perform_check!(st::State) return else st.consecutive_fails += 1 + broadcast_msg("Broadcasting from file: $thisFilePath") logmsg("$ROUTER_IP is unreachable (last result: $routerresult). Consecutive fails: $(st.consecutive_fails)/$FAILS_TO_REBOOT.") save_state(st, StateFilePath) end diff --git a/check_router_reboot_log.txt b/check_router_reboot_log.txt index 5cd362a..7ee8069 100644 --- a/check_router_reboot_log.txt +++ b/check_router_reboot_log.txt @@ -1,40 +1,3 @@ -[2026-03-20T07:22:26.223] DRY RUN: would run reboot command: /bin/systemctl reboot -[2026-03-20T07:22:26.224] Reboot executed (or simulated). Resetting failure counter. -[2026-03-20T07:34:46.993] Starting check loop. Checking router 192.168.88.1 every 60 seconds. -[2026-03-20T07:34:48.140] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 1/3. -[2026-03-20T07:35:48.328] 192.168.88.1 is reachable; resetting consecutive failure counter. -[2026-03-20T07:36:49.337] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 1/3. -[2026-03-20T07:37:50.385] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 2/3. -[2026-03-20T07:38:51.439] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 3/3. -[2026-03-20T07:38:51.451] DRY RUN: would run reboot command: /bin/systemctl reboot -[2026-03-20T07:38:51.452] Reboot executed (or simulated). Resetting failure counter. -[2026-03-20T08:01:26.083] Starting check loop. Checking router 192.168.88.1 every 60 seconds. -[2026-03-20T08:03:30.730] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 1/3. -[2026-03-20T08:04:34.872] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 2/3. -[2026-03-20T08:05:39] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 3/3. -[2026-03-20T08:05:39.012] Executing reboot command: /bin/systemctl reboot -[2026-03-20T08:05:39.019] Reboot executed (or simulated). Resetting failure counter. -[2026-03-20T08:07:37.784] Starting check loop. Checking router 192.168.88.1 every 60 seconds. -[2026-03-20T08:07:42.190] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. -[2026-03-20T08:08:42.390] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:10:13.455] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. -[2026-03-20T08:11:17.576] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. -[2026-03-20T08:12:21.703] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 3/3. -[2026-03-20T08:12:21.703] Cooldown has expired and router is still unreachable. Triggering reboot. -[2026-03-20T08:12:21.715] Executing reboot command: /bin/systemctl reboot -[2026-03-20T08:12:21.722] Reboot executed (or simulated). Resetting failure counter. -[2026-03-20T08:14:14.104] Starting check loop. Checking router 192.168.88.1 every 60 seconds. -[2026-03-20T08:14:14.238] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:15:14.374] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:16:14.436] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:17:14.458] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:18:14.474] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. -[2026-03-20T08:19:45.773] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. -[2026-03-20T08:20:49.912] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. -[2026-03-20T08:21:53.976] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 3/3. -[2026-03-20T08:21:53.976] Cooldown has expired and router is still unreachable. Triggering reboot. -[2026-03-20T08:21:53.988] Executing reboot command: /bin/systemctl reboot -[2026-03-20T08:21:53.995] Reboot executed (or simulated). Resetting failure counter. [2026-03-20T08:24:02.098] Starting check loop. Checking router 192.168.88.1 every 60 seconds. [2026-03-20T08:24:06.510] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. [2026-03-20T08:25:10.722] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. @@ -108,3 +71,40 @@ [2026-03-20T09:04:14.660] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. [2026-03-20T09:05:14.722] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. [2026-03-20T09:06:14.784] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:35:51.399] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T10:36:57.651] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 1/3. +[2026-03-20T10:38:01.299] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 2/3. +[2026-03-20T10:39:02.580] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 3/3. +[2026-03-20T10:39:02.830] Executing reboot command: /bin/systemctl reboot +[2026-03-20T10:39:02.943] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T10:40:30.096] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T10:40:32.940] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. +[2026-03-20T10:41:34.658] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. +[2026-03-20T10:42:35.734] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 3/3. +[2026-03-20T10:42:35.738] Cooldown has expired and router is still unreachable. Triggering reboot. +[2026-03-20T10:42:35.839] Executing reboot command: /bin/systemctl reboot +[2026-03-20T10:42:35.917] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T10:43:57.053] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T10:43:59.937] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. +[2026-03-20T10:45:01.576] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. +[2026-03-20T10:46:02.604] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 3/3. +[2026-03-20T10:46:02.608] Cooldown has expired and router is still unreachable. Triggering reboot. +[2026-03-20T10:46:02.700] Executing reboot command: /bin/systemctl reboot +[2026-03-20T10:46:02.900] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T10:47:22.509] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T10:47:25.404] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. +[2026-03-20T10:48:27.041] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 2/3. +[2026-03-20T10:49:28.096] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 3/3. +[2026-03-20T10:49:28.100] Cooldown has expired and router is still unreachable. Triggering reboot. +[2026-03-20T10:49:28.350] Executing reboot command: /bin/systemctl reboot +[2026-03-20T10:49:28.409] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T10:50:49.333] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T10:50:50.033] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:51:50.626] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:52:50.699] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:53:50.763] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:54:50.784] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:55:50.800] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:56:51.025] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:57:51.056] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state. +[2026-03-20T10:58:51.132] 192.168.88.1 is reachable during cooldown. Router is back online! Resetting state.