Community discussions

 
User avatar
petrb
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 96
Joined: Thu Jan 26, 2017 4:17 pm

Hysteresis watchdog

Sun Oct 28, 2018 4:59 pm

Hi, the example implementation of the watchdog with the hysteresis (for the OSPF routing protocol, it can be easily modified for any other purpose). How it works: - start the cycle in the background that sends ICMP each second to the target. When packet loss is detected, the trigger is called. A script can be stopped with the command: :set hysteresis stop
:local DSTIP "10.255.255.2"
:local INTERFACE "ether4-wifi60G"
:local timer 0
:local pause false
:global hysteresis start

while ($hysteresis != "stop") do={
  if ($timer = 0) do={
    if ([/ping $DSTIP count=1] = 0) do={
      if ($pause = false) do={
        :set timer 30
        :set pause true
        :log info "60G backup activated"
        /routing ospf interface set [find where interface=$INTERFACE] passive=yes
      }
    } else={
      if ($pause = true) do={
        :set pause false
        /routing ospf interface set [find where interface=$INTERFACE] passive=no
        :log info "60G restored"
      }
    }
  }
  if ($timer > 0) do={:set timer ($timer-1)}
  delay 1
}
Did you read manual? .... What? .... Read the manual.

Who is online

Users browsing this forum: No registered users and 5 guests