Description
Netwatch monitors state of hosts on the network. It does so by sending ICMP pings to the list of
specified IP addresses. For each entry in netwatch table you can specify IP address, ping interval
and console scripts. The main advantage of netwatch is it's ability to issue arbitrary console
commands on host state changes.
Property Description
down-script ( name ) - a console script that is executed once when state of a host changes from
unknown or up to down
host ( IP address ; default: 0.0.0.0 ) - IP address of host that should be monitored
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
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
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
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@MikroTik] system script> add name=gw_1 source={/ip route set
{... [/ip route find dst 0.0.0.0] gateway 10.0.0.1}
[admin@MikroTik] system script> add name=gw_2 source={/ip route set
{.. [/ip route find dst 0.0.0.0] gateway 10.0.0.217}
[admin@MikroTik] system script> /tool netwatch
[admin@MikroTik] tool netwatch> add host=10.0.0.217 interval=10s timeout=998ms \
\... up-script=gw_2 down-script=gw_1
[admin@MikroTik] tool netwatch> print
Flags: X - disabled
#
HOST
TIMEOUT
INTERVAL
STATUS
0
10.0.0.217
997ms
10s
up
[admin@MikroTik] 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@MikroTik] 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
Page 625 of 695
Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
Содержание RouterOS v2.9
Страница 1: ...MikroTik RouterOS v2 9 Reference Manual ...