How to use monit to reboot firewall when VPN gateway is not reachable for X min

Started by skywalker007, March 13, 2020, 02:59:14 PM

Previous topic - Next topic
I am looking for some advise for how to use monit to achieve the following:
I have a remote OPNsense which uses an OPNvpn site to site tunnel to my main site.
Now when the remote OPNsense can't reach the destination gateway, i want to wait for X min and then reboot.
Now after reboot, if it doesn't reconnect  - obviously the problem is somewhere else and I want to add an additional delay before rebooting again and so on. Once connection is established it shoud revert back to the default delay of course.
Do I need to write some shell script for that exercise or can monit do it out of the box?

thanks!
System1: Qotom Q310G4 (died recently)
System1: Supermicro A2SDi-4C-HLN4F,  64GB RAM, ZFS mirrored boot drive
System2: APU2C4

Under service settings add your VPN service then go to the Service Tests tab.

In the service tests tab, set your preferred condition you want to meet before doing a restart. Set the action to execute, then set the path to /sbin/shutdown -r now.

Then assign the test to your VPN service.