Monitoring gateways with Monit

Started by DCLR, February 09, 2023, 11:02:01 AM

Previous topic - Next topic
I've been chasing my tail for a few days trying to put this together, but not finding what I need--a basic how-to for monitoring gateways in OPNsense.

I have two gateways with two different providers configured for failover. Failover works surprisingly well, much better than most commercial (enterprise-grade) firewalls I've used, but the one thing I'm still missing is email/SMS notification when one of my providers goes down. I've been studying and researching Monit and looking for an obvious way to pick up the gateway status, but everything I've found comes just short of the answer.

Can someone give me a basic rundown of how to make this work?

Thanks!


Quote from: Greelan on February 09, 2023, 11:12:04 AM
Yep: https://forum.opnsense.org/index.php?topic=18745.msg97953#msg97953

Thanks for the link, but it deals with restarting dpinger when it fails. What I need is a way to evaluate dpinger's result, specifically an alert when a gateway goes down.

Thanks!

Assuming you have your SMTP server setup correctly in the "General Settings" tab of Monit, AND you have your email configured correctly in "Alert Settings" you only need 1 more step:

1. Service Settings Tab
Add, if not already present, and enable a "gateway_alert" service.  Within that service just ensure that the "Path" value is set to "/usr/local/opnsense/scripts/OPNsense/Monit/gateway_alert" (no quotes) and the "Tests" value is set to "NonZeroStatus" or I believe you can use "ChangedStatus" as well.
OPNsense 25.1.9 running on:
Dell Optiplex 3050
Intel I5-7600 @ 3.5Ghz (4 Cores)
Intel I350-T4 Nic
8G DDR4
256G SSD