I'll try to make a script to check a WAN status, the case is:
USB Modem on RB.
In case of blocking of only the connectivity to a usb reset for some times, after X times to reboot of RB.
I'll try with this code, but not work:
Code: Select all
{
:log warning "START-SCRITP CONTROLL"
:global CheckTimes;
:global CheckRunStatus;
:log error "logCheckTimes = $CheckTimes"
:log error "logCheckRunStatus = $CheckRunStatus"
:if ($CheckRunStatus = 1) do={
:log error "Allready running..."
:error break;
} else={
:set CheckRunStatus 1;
:if ($CheckTimes = 5) do={
:log error "Reboot now"
/system reboot;
} else={
:local HOST "8.8.8.8"
:local PINGCOUNT "30"
:local DELAY "10s"
:if ([/ping $HOST interval=1 count=$PINGCOUNT] = 0) do={
:log error "HOST $HOST is not responding to ping request, reseting USB interface ..."
/system routerboard usb power-reset duration=10s;
:log error "USB is now disabled, waiting $DELAY ..."
:delay $DELAY;
:local app $CheckTimes+1;
:set CheckTimes $app;
} else {
:log warning "HOST $HOST ping is ok, no need to take any action ...";
:set CheckRunStatus 0;
:set CheckTimes 0;
}
:set CheckRunStatus 0;
}
}
:log warning "END-SCRITP CONTROLL";
}