Last active
October 22, 2022 19:59
-
-
Save tlatsas/cb24ea573b62be1ebe21dfdf26afceda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:delay 15; | |
/tool sms send lte1 <phone> message="Mikrotik LTE rebooted successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:local continue true; | |
:local counter 0; | |
:local maxcounter 10; | |
:local sleepseconds 5; | |
:local goodpings 0; | |
:while ($continue) do={ | |
:set counter ($counter + 1); | |
:delay $sleepseconds; | |
:if ([/ping 1.1.1.1 interval=1 count=1] =0) do={ | |
:log warning "Ping to WAN failed on attempt $counter of $maxcounter - Will try again in $sleepseconds seconds."; | |
} else { | |
:log info "Internet connection looks up from here. Nothing to do."; | |
:set continue false; | |
:set goodpings ($goodpings +1); | |
}; | |
:if ($counter=$maxcounter) do={ | |
:set continue false; | |
} | |
} | |
:if ($goodpings = 0) do={ | |
:log info "No internet connection found. Rebooting in 10 seconds"; | |
:delay 10; | |
/system reboot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment