Page 1 of 1

netwatch for two IPs

Posted: Mon May 23, 2022 4:08 pm
by baxenko
Hello. Unfortunately netwatch in Mikrotik can only ping one IP address. Therefore, I ask for help to write a script that will allow you to ping two IP addresses. If at least one of them is available, then disable the IP, if both are not available, then enable the IP.

I tried to do it but it doesn't work.
:local ipone "10.10.1.254";
:local iptwo "10.10.1.8";
:local pingsofone [ping $ipone count=3];
:local pingsoftwo [ping $iptwo count=3];
if (($pingsofone<1)&&($pingsoftwo<1)) do={/ip address enable [find comment="rezerv"];};
if (($pingsofone>1)||($pingsoftwo>1)) do={/ip address disable [find comment="rezerv"]}

Re: netwatch for two IPs  [SOLVED]

Posted: Mon May 23, 2022 4:50 pm
by rextended
if (($pingsofone<1)&&($pingsoftwo<1)
) ???

"if if" ?

ip address enabled [find comment=rezerv]
enabled ???

ip address disabled [find comment=rezerv]
disabled ???


You can not create script putting random words at random randomness...



{

:local ipone 10.10.1.254
:local iptwo 10.10.1.8
:local pingsofone [ping $ipone count=3]
:local pingsoftwo [ping $iptwo count=3]
:if ( ($pingsofone < 1) and ($pingsoftwo < 1) ) do={ 
    /ip address  enable [find where comment="rezerv"]
}
:if ( ($pingsofone > 1) or  ($pingsoftwo > 1) ) do={
    /ip address disable [find where comment="rezerv"]
}

}

Re: netwatch for two IPs

Posted: Mon May 23, 2022 7:52 pm
by baxenko
there was a copy error
:local ipone "10.10.1.254";
:local iptwo "10.10.1.8";
:local pingsofone [ping $ipone count=3];
:local pingsoftwo [ping $iptwo count=3];
if (($pingsofone<1)&&($pingsoftwo<1)) do={/ip address enable [find comment="rezerv"];};
if (($pingsofone>1)||($pingsoftwo>1)) do={/ip address disable [find comment="rezerv"]}
ty, Slava Ukraine!

Re: netwatch for two IPs

Posted: Mon May 23, 2022 10:01 pm
by rextended
ty, Slava Ukraine!
😢🩸