I started a topic in another section of this forum - but the following actually now belongs here...
This is a step by step procedure to configure a mikrotik to auto-reboot after pings to a remote IP address have gone un-answered for 5 minutes.
Note - The Mikrotk Watchdog "Watch IP address" reboots in 60 seconds - not what I wanted
Note - The Mikrotik Netwatch has a sliding window where a down action could happen in as little as a few seconds - not what I wanted
I wanted a way to auto reboot my mikrotk after 5 minutes. This way I can reboot all kinds of servers and links elsewhere and not trigger my mikrotkks to auto-reboot.
OK - I finally got something working to do what I wanted.
First - what this does:
#1 It will ping test an IP address. This can be a remote IP address
#2 If the remote IP address does not answer any pings for about 5 minutes, then the router reboots.
To set it up - follow these steps using Winbox:
Note: In my example I am testing to remote IP address 192.0.2.254
Note: You will need to change anything I have below from 192.0.2.254 to your IP address you wish to test.
Note: Example if you will be testing 10.10.18.5 then change stuff like what is shown below
Note: "NetWatchBoot-192.0.2.254" would be changed to "NetWatchBoot-10.10.18.5"
A - (Optional) - remove the IP address from System-->Watchdog-->Watch Address
B - Go to System-->Scripts
Click on the red "+"
Give your script a Name (in my example I will use "NetWatchBoot-192.0.2.254"
C - In the Source: area paste in the entire line below:
:if ([/ping 192.0.2.254 interval=5 count=60] =0) do={
log info "my ping watchdog is down" ; /system reboot
}
D - Click the Apply button - then click the OK button
At this time - we have a script - it is not running or active yet.
E - Go to Tools-->Netwatch
Click on the red "+"
On the Host tab - type in 192.0.2.254
(Your IP address may be different - it is the same IP address you used from "B" above)
F - Click on the Down tab
Paste in the line below:
/system script run NetWatchBoot-192.0.2.254
G - Click the Apply button - then click the OK button
---- You are done -----
Your system will now auto reboot only after 5 (up to 6) minutes of the remote IP address not pinging.
If you want to disable the auto-reboot function, all you need to do is:
Tools-->Netwatch and disable the line that shows the IP address you are testing to.
-------------------------------------------------------------------------------
What is nice about this is - if you are testing to a server or something and that server takes longer
than 60 seconds to reboot, your mikrotik will not reboot. The remote IP address has to be down for 5 (to 6) minutes
to trigger an automatic reboot.
---------------------
and yes - i know I could of thrown this is the schedular instead of triggering my script from netwatch - but I like it more this way
FYI - This is my first use of Mikrotik script and Mikrotik netwatch
I hope this help others - if it works for you then please post a reply
Tom Jones
A WISP up in North Idaho