Community discussions

MikroTik App
 
fqx
newbie
Topic Author
Posts: 27
Joined: Tue Dec 20, 2016 2:24 pm

script working in scripting won't work in netwatch, not a permission issue

Sat Apr 09, 2022 4:55 am

:local HOST "192.168.1.1"
:local PINGCOUNT "10"
:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:delay 10s
:if ([/ping $HOST interval=1 count=$PINGCOUNT] = 0) do={
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."
} else={
:log info "$INTF is working.";
}


Above works in scripting and scheduler


:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."

These lines won't work in Netwatch, and I don't know why.
Only seen "Interface sfp-sfpplus1 is down, restarting..." in logging.
RB5009 RouterOS 7.2
Last edited by fqx on Mon Apr 11, 2022 5:16 am, edited 4 times in total.
 
fqx
newbie
Topic Author
Posts: 27
Joined: Tue Dec 20, 2016 2:24 pm

Re: Don't know why this script not work

Sat Apr 09, 2022 5:17 am

Oh, I need to delete the space after "do"
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Don't know why this script not work

Sat Apr 09, 2022 2:23 pm

Why not use netwatch function?
Its created for just this type of senarios.
 
fqx
newbie
Topic Author
Posts: 27
Joined: Tue Dec 20, 2016 2:24 pm

Re: Don't know why this script not work

Sun Apr 10, 2022 5:50 am

Why not use netwatch function?
Its created for just this type of senarios.
I didn't know that, will look it up later.
Thank you.
 
fqx
newbie
Topic Author
Posts: 27
Joined: Tue Dec 20, 2016 2:24 pm

Re: Don't know why this script not work

Sun Apr 10, 2022 6:24 am

Why not use netwatch function?
Its created for just this type of senarios.

:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."

These lines won't work in Netwatch, and I don't know why.
Only seen "Interface sfp-sfpplus1 is down, restarting..." in logging.

Who is online

Users browsing this forum: No registered users and 18 guests