Page 1 of 1
Netwatch II
Posted: Tue Oct 14, 2008 11:06 pm
by quickgen
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
![Sad :(](./images/smilies/icon_sad.gif)
Re: Netwatch II
Posted: Wed Oct 15, 2008 8:56 am
by mrz
: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;
}
Re: Netwatch II
Posted: Wed Oct 15, 2008 3:49 pm
by quickgen
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.
Re: Netwatch II
Posted: Wed Oct 15, 2008 4:00 pm
by mrz
sorry, script edited. It is working on my router.
Re: Netwatch II
Posted: Wed Oct 15, 2008 7:19 pm
by quickgen
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?
Re: Netwatch II
Posted: Thu Oct 16, 2008 8:25 am
by mrz
Run script manually from console, if there are any errors they will be shown in console output.
Re: Netwatch II
Posted: Thu Oct 16, 2008 1:13 pm
by quickgen
mrz, I did test the script from console and it gives me the same errors as in my previous messages.
Re: Netwatch II
Posted: Thu Oct 16, 2008 1:20 pm
by mrz
1) 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.
2) You need route in routing table with comment "Default Route"
Script is working if both conditions above are met.
Re: Netwatch II
Posted: Thu Oct 16, 2008 1:23 pm
by quickgen
1) 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.
I didn't know that you have to put the script in { }. Thank you. I will try later.
Re: Netwatch II
Posted: Sun Oct 19, 2008 1:32 am
by quickgen
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.