Setup guide

interval (time; default: 1s) - the time between pings. Lowering this will make state changes more
responsive, but can create unnecessary traffic and consume system resources
timeout (time; default: 1s) - timeout for each ping. If no reply from a host is received during this
time, the host is considered unreachable (down)
up-script (name) - a console script that is executed once when state of a host changes from
unknown or down to up
down-script (name) - a console script that is executed once when state of a host changes from
unknown or up to down
since (read-only: time) - indicates when state of the host changed last time
status (read-only: up | down | unknown) - shows the current status of the host
up - the host is up
down - the host is down
unknown - after any properties of this list entry were changed, or the item is enabled or
disabled
Example
This example will run the scripts gw_1 or gw_2 which change the default gateway depending on
the status of one of the gateways:
[admin@Wandy] system script> add name=gw_1 source={/ip route set
{... [/ip route find dst 0.0.0.0] gateway 10.0.0.1}
[admin@Wandy] system script> add name=gw_2 source={/ip route set
{.. [/ip route find dst 0.0.0.0] gateway 10.0.0.217}
[admin@Wandy] system script> /tool netwatch
[admin@Wandy] tool netwatch> add host=10.0.0.217 interval=10s timeout=998ms \
\... up-script=gw_2 down-script=gw_1
[admin@Wandy] tool netwatch> print
Flags: X - disabled
# HOST TIMEOUT INTERVAL STATUS
0 10.0.0.217 997ms 10s up
[admin@Wandy] tool netwatch> print detail
Flags: X - disabled
0 host=10.0.0.217 timeout=997ms interval=10s since=feb/27/2003 14:01:03
status=up up-script=gw_2 down-script=gw_1
[admin@Wandy] tool netwatch>
Without scripts, netwatch can be used just as an information tool to see which links are up, or which
specific hosts are running at the moment.
Let's look at the example above - it changes default route if gateway becomes unreachable. How it's
done? There are two scripts. The script "gw_2" is executed once when status of host changes to up.
In our case, it's equivalent to entering this console command:
[admin@Wandy] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.217
The /ip route find dst 0.0.0.0 command returns list of all routes whose dst-address value is
0.0.0.0. Usually, that is the default route. It is substituted as first argument to /ip route set
command, which changes gateway of this route to 10.0.0.217
The script "gw_1" is executed once when status of host becomes down. It does the following:
[admin@Wandy] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.1
It changes the default gateway if 10.0.0.217 address has become unreachable.
Here is another example, that sends e-mail notification whenever the 10.0.0.215 host goes down:
[admin@Wandy] system script> add name=e-down source={/tool e-mail send
{... from="rieks@mt.lv" server="159.148.147.198" body="Router down"
{... subject="Router at second floor is down" to="rieks@latnet.lv"}
[admin@Wandy] system script> add name=e-up source={/tool e-mail send
{... from="rieks@mt.lv" server="159.148.147.198" body="Router up"