From 638e05a13a6f6166500aa0be3327898f28872aee Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Fri, 20 Mar 2026 15:25:52 +0700 Subject: [PATCH] update --- check_and_reboot_state.json | 2 +- check_router_reboot.jl | 12 ++++++++---- check_router_reboot_log.txt | 16 ++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/check_and_reboot_state.json b/check_and_reboot_state.json index 42dcf12..84c6491 100644 --- a/check_and_reboot_state.json +++ b/check_and_reboot_state.json @@ -1 +1 @@ -{"last_reboot_datetime":"2026-03-20T14:46:18.848","consecutive_fails":0} \ No newline at end of file +{"last_reboot_datetime":"2026-03-20T15:23:19.868","consecutive_fails":2} \ No newline at end of file diff --git a/check_router_reboot.jl b/check_router_reboot.jl index b5cc2c4..89a0cec 100644 --- a/check_router_reboot.jl +++ b/check_router_reboot.jl @@ -25,8 +25,8 @@ const TIMEOUT_SECS = 30 # request timeout const ATTEMPTS_PER_CHECK = 1 # number of ping attempts per check const BACKOFF_BETWEEN_ATTEMPTS = 1 # seconds between ping attempts const FAILS_TO_REBOOT = 3 # consecutive failed checks required to trigger reboot -const COOLDOWN_AFTER_REBOOT_SECS = 120 # do not reboot again within this many seconds -const DRY_RUN = true # set false to actually reboot +const COOLDOWN_AFTER_REBOOT_SECS = 300 # do not reboot again within this many seconds +const DRY_RUN = false # set false to actually reboot const CHECK_INTERVAL_SECS = 60 # run a check every CHECK_INTERVAL_SECS seconds const thisFolderPath = @__DIR__ @@ -237,8 +237,12 @@ function perform_check!(st::State) success = false last_result = nothing for i in 1:ATTEMPTS_PER_CHECK - # ok, result = check_router_once(ROUTER_IP) - ok, result = values(JSON.parsefile("/home/ton/docker-programs/check_and_reboot/test_ping_result.json")) # for testing without actual ping + + # # for testing without actual ping + # ok, result = values(JSON.parsefile("/home/ton/docker-programs/check_and_reboot/test_ping_result.json")) + + ok, result = check_router_once(ROUTER_IP) + if ok success = true break diff --git a/check_router_reboot_log.txt b/check_router_reboot_log.txt index e85e30a..a42c524 100644 --- a/check_router_reboot_log.txt +++ b/check_router_reboot_log.txt @@ -1,11 +1,3 @@ -[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. @@ -106,3 +98,11 @@ [2026-03-20T14:46:18.745] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 3/3. [2026-03-20T14:46:18.841] DRY RUN: would run reboot command: /usr/bin/sudo systemctl reboot [2026-03-20T14:46:18.844] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T15:21:15.466] Starting check loop. Checking router 192.168.88.1 every 60 seconds. +[2026-03-20T15:21:17.191] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 1/3. +[2026-03-20T15:22:18.736] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 2/3. +[2026-03-20T15:23:19.802] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 3/3. +[2026-03-20T15:23:19.865] DRY RUN: would run reboot command: /bin/systemctl reboot +[2026-03-20T15:23:19.867] Reboot executed (or simulated). Resetting failure counter. +[2026-03-20T15:24:21.083] 192.168.88.1 is unreachable during cooldown. Consecutive fails: 1/3. +[2026-03-20T15:25:22.150] 192.168.88.1 is unreachable (last result: no response). Consecutive fails: 2/3.