Hi there
I want to put some lines in a netwatch monitor to check for an ip.
If that ip is not responding, run the script that has to do something like this:
disable interface ether0
wait 5 seconds
enable interface ether0
check ip
loop if necesary
Hope there is an easy solution.
Thanks
Matias
nmaton
August 24, 2012, 1:05pm
2
i have done the same and used the following command :
/tool netwatch
add disabled=no down-script=“interface eoip enable eoip-tunnel1\r
\n/interface eoip enable eoip-tunnel2\r
\n/interface eoip enable eoip-tunnel3” host=10.1.1.254 interval=1s timeout=1s50
up-script=“interface eoip disable eoip-tunnel1\r
\n/interface eoip disable eoip-tunnel2\r
\n/interface eoip disable eoip-tunnel3”
However i have noticed that netwatch doesnt do it always … sometimes it works sometimes it doesnt .
Maybee some expert knows a better way to do this??
I don’t think your advice will work, as I am pinging a host behind the interface I want to disable.
So if I disable it, I can not do the ScriptUp script.
I want to disable, wait some time, then enable and test the host again.
Thanks btw
The looping is what complicates this most…
You can simply use:
/interface disable ether0
:delay 5
/interface enable ether0
as your down script, but as written, it would only try this one.
As much I recall you can not address ports directly and use a item index for that.
I use Netwatch tool with that script:
http://forum.mikrotik.com/t/eht1-port-shuts-down/58697/2
Try give this a spin:
/system script
add name="Restart ether0" \
source=":global runningRestartEther0\r\
\n:if ([:len \$runningRestartEther0] = 0 || \$runningRestartEther0 = 0) do\
={\r\
\n /interface {\r\
\n :set runningRestartEther0 1\r\
\n :local o [find name=\"ether0\"]\r\
\n set \$o disabled=yes\r\
\n :delay 5\r\
\n set \$o disabled=no\r\
\n :delay 2\r\
\n :set runningRestartEther0 0\r\
\n }\r\
\n}\r\
\n"
/system scheduler
add name="Restart ether0" on-event="Restart ether0" \
start-date=jan/01/1970 start-time=00:00:00 interval=2s
/tool netwatch
add host=1.1.1.1 \
down-script="/system scheduler set [find name=\"Restart ether0\"] disabled=no" \
up-script="/system scheduler set [find name=\"Restart ether0\"] disabled=yes"