Community discussions

MikroTik App
 
Lightningpillz
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 2:44 pm

Route down log indication

Mon Sep 04, 2023 5:05 pm

Hi,
Looking to implement a check to confirm if routes are up and running for various subnets. Trying to get it working with Netwatch and an output to log at the moment but a major issue in the Loop that my inferior scripting skills have not managed to solve, so I turn to the forum for assistance.

Thanks to @Jotne for getting me this far with his post viewtopic.php?p=888800#p888800

Netwatch:
Host - 8.8.8.8
Up - Pointing to script "Test"
Down - Pointing to script "Test"

Script:
Name - Test
Source -
:local Host $host
/tool netwatch
:local Status [get [find where host="$Host"] status]
:while ($Status="down") do= {:log error "Down"}

This currently outputs an endless barrage of error log "Down" without end, only way I've found is a reboot. How can I get this error message to loop every minute if the netwatch status is marked as down and then to stop when status is up?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Route down log indication

Mon Sep 04, 2023 7:11 pm

This currently outputs an endless barrage of error log "Down" without end.
Is exactly what you want/write:
while $Status is down, write to error log "Down"...

If you had written instead:
if $tatus is down, write to error log "Down"...
 
Lightningpillz
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 2:44 pm

Re: Route down log indication

Tue Sep 05, 2023 9:46 am

This currently outputs an endless barrage of error log "Down" without end.
Is exactly what you want/write:
while $Status is down, write to error log "Down"...

If you had written instead:
if $tatus is down, write to error log "Down"...

Had already tried this however with logic it only outputs to log once. How would one go about getting this to repeat until the Status is noted as "up"?
:local Host $host
/tool netwatch
:local Status [get [find where host="$Host"] status]
:if ($Status="down") do={:log error "ITS DOWN"} else={:log error "ITS UP"}
 
Lightningpillz
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 2:44 pm

Re: Route down log indication  [SOLVED]

Fri Sep 08, 2023 4:36 pm

ChatGPT gave me the answer
:while ($Status="down") do={
    :log error "Down"
    :delay 1000ms
    :set Status [get [find where host="$Host"] status] #THIS needs to check the var every time
}

Who is online

Users browsing this forum: No registered users and 8 guests