I have this script that checks the connection of a wireguard tunnel between two sites.
Code: Select all
:if ([/ping 192.168.88.1 interval=500ms count=10]<8) do={
:local deviceName [/system/identity/get name]
:local iFaceName "wg-sts"
:log error "Wireguard: Tunnel with SiteB is down! Reconnecting...";
# Reset wg-peer to SiteB
/interface/wireguard/peers/disable [find interface=$iFaceName]
:delay 5
/interface/wireguard/peers/enable [find interface=$iFaceName]
# Check connectivity after 60 seconds
:delay 60
:if ([/ping 192.168.88.1 interval=500ms count=5] = 5) do={
:log info "Verified WireGuard connection to SiteB -> OK!"
}
}
In Scheduler I have a task to run every 1 minute, but I would like that if after 10 attempts (10 minutes) it could not connect to the other end, to try again after 60 minutes. Is there any way to do it?
Thanks as always.