I was using this script http://wiki.mikrotik.com/wiki/Improved_Netwatch_II for a couple of years without a problem on my 2.9.xx Mikrotik.
I had bought a license for Mikrotik 3.x and the same script doesn’t work with 3.14
Can somebody adapt it to version 3.14? Without documentation on 3.x scripting host, I can’t figure out there the problem lies in the script ![]()
:local i 0;
{
:do {
:set i ($i + 1);
} while=(($i < 5) && ([/ping xx.xx.xx.xx interval=3 count=1]=0))
:if ($i=5 && [/ip route get [find comment="Default Route"] distance]=1) do={
:log info "Main Gateway down";
/ip route set [find comment="Default Route"] distance=3;
}
mrz Thank you, but it just keeps saying:
For
:set i ($i + 1);
this error:
expected variable name (line 1 column 6)
For
:if ($i=5 && [/ip route get [find comment=“Default Route”]
distance]=1
this error:
syntax error (line 1 column 17)
Then I just launch the script by pressing Run Script, only silence I hear.
sorry, script edited. It is working on my router.
Sorry to say, but I had tried to paste it with spaces, without spaces…all the ways i could invent ![]()
Nothing! nothing! nothing! ![]()
Then I launch it, it’s not even pinging the host. I can judge this by looking at the counters of my icmp rule.
Then I create a simple script, that just pings(/ping xx.xx.xx.xx), the counters show that it’s working and in /ip firewall connections I clearly see this.
WTF i’m doing wrong?
Run script manually from console, if there are any errors they will be shown in console output.
mrz, I did test the script from console and it gives me the same errors as in my previous messages.
-
When you paste script directly in console then put it all in { }.
otherwise first line where local i is defined will be treated as another script. -
You need route in routing table with comment “Default Route”
Script is working if both conditions above are met.
I didn’t know that you have to put the script in { }. Thank you. I will try later.
mrz your script is working ok with one more } at the end.
So the final script look like:
:local i 0;
{
:do {
:set i ($i + 1);
} while=(($i < 5) && ([/ping xx.xx.xx.xx interval=3 count=1]=0))
:if ($i=5 && [/ip route get [find comment=“Default Route”] distance]=1) do={
:log info “Main Gateway down”;
/ip route set [find comment=“Default Route”] distance=3;
}
}
Big thanks for your help.