Netwatch script in vyos

Hello is possible to create “netwatch” script in vyos ? I need to check some IP and if is down, i need to change nat rule. if is up, change it back. Thank you for help… Is here somebody who can help me with this?

Custom scripts using task scheduler, which is once again available in 1.4: Task Scheduler — VyOS 1.4.x (sagitta) documentation
So far, no native/clen way to achieve that “netwatch” functionality that you request.
You can alwasys sumbit a feature request in https://phabricator.vyos.net/

@n.fort I assume that the “netwatch” term is borrowed from Mikrotik RouterOS.
The basics there are couple parameters:

  • host
  • type [simple,icmp,tcp-conn,http-get]
  • interval
  • timeout
  • start-delay

And some stats such as:

  • status [unknown,down,up]
  • since (current state since…)
  • Done tests: (integer)
  • Failed Tests: (integer)

Custom scripts in three different stages of the test:

  • Up
  • Down
  • Test ( don’t know yet what it is about)

It would be pretty simple to write couple scripts to do just that which will be able to pass one to the other with some env variables.
As for the statistics, it would be pretty easy to store them in plain text or json/yaml files.
Regular cron jobs would not be good enough because their minimum interval is 1 Minute(60s) while ping tests are sometimes done every second.

I believe that simple nagios checks plugins scripts can be used to supply a set of basic tests.
Also couple “on state” change[up,down] scripts can supplied for email,sms,telegram,other http, etc.

Do you think we can make it work somehow?
I can try to work on somethings.

I think I can separate this whole process into couple components:

  • check scripts
  • status change scripts (which will be triggered for statistics updates and triggering another external script)
  • statistics data collector and displayed (can be seen from vtysh show command)

A project?

Something like this check-scripts and some routing decisions in PR1358
Maybe some logic from it will be helpful