OPNsense Forum

English Forums => General Discussion => Topic started by: DCLR on February 09, 2023, 11:02:01 AM

Title: Monitoring gateways with Monit
Post by: DCLR on February 09, 2023, 11:02:01 AM
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!
Title: Re: Monitoring gateways with Monit
Post by: Greelan on February 09, 2023, 11:12:04 AM
Yep: https://forum.opnsense.org/index.php?topic=18745.msg97953#msg97953
Title: Re: Monitoring gateways with Monit
Post by: DCLR on February 09, 2023, 11:55:07 AM
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!
Title: Re: Monitoring gateways with Monit
Post by: axsdenied on February 09, 2023, 08:11:32 PM
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.
Title: Re: Monitoring gateways with Monit
Post by: DCLR on February 10, 2023, 04:27:49 AM
Thank you! Just what I needed.