Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Last active October 22, 2022 19:59
Show Gist options
  • Save tlatsas/cb24ea573b62be1ebe21dfdf26afceda to your computer and use it in GitHub Desktop.
Save tlatsas/cb24ea573b62be1ebe21dfdf26afceda to your computer and use it in GitHub Desktop.
:delay 15;
/tool sms send lte1 <phone> message="Mikrotik LTE rebooted successfully"
: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