Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
Use monit to test for interface down?
« previous
next »
Print
Pages: [
1
]
Author
Topic: Use monit to test for interface down? (Read 2139 times)
patrick3000
Jr. Member
Posts: 87
Karma: 6
Use monit to test for interface down?
«
on:
April 28, 2023, 07:52:47 pm »
I have two WANS, a primary WAN and a secondary WAN, and a gateway group with failover from primary WAN to secondary WAN when primary WAN goes down.
I would like to use Monit, available under "services," to send an email notifying me when either WAN goes down. I looked in the OPNsense documentation for Monit and didn't see anything about notification when an interface goes down.
So I'm wondering: before I spend the time setting up Monit and configuring it with my email, is this something that Monit can do? Does anyone have some tips on the setup?
«
Last Edit: April 28, 2023, 07:54:18 pm by patrick3000
»
Logged
FullyBorked
Sr. Member
Posts: 343
Karma: 24
Re: Use monit to test for interface down?
«
Reply #1 on:
May 01, 2023, 05:25:22 pm »
Yes it's possible there is even a built in script for this, I've been using this for years.
Go to Services/Monit/Settings.
Alert Settings - assume you have other alerts setup and working
Under Service Settings create a new service call it - gateway_alert.
Type - Custom
Path - /usr/local/opnsense/scripts/OPNsense/Monit/gateway_alert
Tests - NonZeroStatus
Description - Monitors for gateway status changes and failover.
Logged
kpiq
Newbie
Posts: 30
Karma: 3
Re: Use monit to test for interface down?
«
Reply #2 on:
May 09, 2023, 04:06:02 am »
Well, there is a problem with that. It had been some time since I noticed that Monit was not alerting me of loss of internet connectivity. Today I disconnected my cable modem and ran /usr/local/opnsense/scripts/OPNsense/Monit/gateway_alert. It keeps getting an exit code of 0, no matter what.
«
Last Edit: May 09, 2023, 04:08:06 am by kpiq
»
Logged
kpiq
Newbie
Posts: 30
Karma: 3
Re: Use monit to test for interface down?
«
Reply #3 on:
May 27, 2023, 12:07:10 am »
In order for these steps to work there is one missing piece that I was unaware of. That script monitores gateway groups, not single gateways. In addition to the steps provide by FullyBorked (great job!) you need to:
Create a Gateway Group (System > Gateway > Group).
Include in that group only the WAN interface. Don't worry about any others. If you have others and want to monitor them too you'll need separate Gateway Groups.
Choose the Trigger. I like Packet Loss and High Latency. It just works!
Save and Apply.
Now the script will alert you for sure. See
https://github.com/opnsense/core/issues/6562
.
Thanks to AdSchellevis (
https://github.com/AdSchellevis
) for the information.
«
Last Edit: May 27, 2023, 12:11:06 am by kpiq
»
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
Use monit to test for interface down?