Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
19.1 Legacy Series
»
Monit setup to notify on connectivity change
« previous
next »
Print
Pages: [
1
]
Author
Topic: Monit setup to notify on connectivity change (Read 3028 times)
cpw
Jr. Member
Posts: 71
Karma: 4
Monit setup to notify on connectivity change
«
on:
May 23, 2019, 06:52:26 am »
Hi. Last one, promise!
So, I'd like to know if anyone has successfully setup monit to monitor network interface state changes, and used them to generate some kind of event? My old setup used a pinger similar to dpinger, but when it detected a state change, I could call an arbitrary script, which I used to post a message to an MQTT topic, where other things could act on the "downed" interface.
In OPNSense, it looks like monit is supposed to be
how
you do this kind of activity, but quite frankly, it's a complete headscratcher how you'd actually accomplish doing it. I'm guessing I need to monitor the connection, but which connection, how? What do I put in the query expression? Are there placeholders for
re0
or whatever?
If monit is not the solution to this problem, how do I do it? I want to dispatch
something
when connectivity changes, either through DHCP address change, or ISP having a bad day and making a mess of their routing tables, or thunder striking the telco node outside my house and frying the local telephony infrastructure (all have happened in the past 15 years living here).
Many thanks for any help!
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: Monit setup to notify on connectivity change
«
Reply #1 on:
May 23, 2019, 07:32:10 pm »
Hi cpw,
There's a system facility called rc.syshook which offers a couple of endpoints for core pr plugin functionality to be called in a serialised, ordered fashion:
https://docs.opnsense.org/development/backend/autorun.html
What's probably most interesting here is the "monitor" event which corresponds with a dpinger event. "carp" is in there too to detect state changes. The caveat with monitor is that it's a new event which is only available on 19.7 development version for the time being.
https://github.com/opnsense/core/tree/master/src/etc/rc.syshook.d
(all the core events and scripts)
https://github.com/opnsense/core/blob/master/src/etc/rc.syshook
(the shell script called for an event)
Hope that helps.
Cheers,
Franco
Logged
cpw
Jr. Member
Posts: 71
Karma: 4
Re: Monit setup to notify on connectivity change
«
Reply #2 on:
May 24, 2019, 05:57:50 am »
Interesting. This definitely looks like a possible way forward. Is there any documentation on what is available in the script (env vars)?
It looks like it might be a way to do external notification on connectivity change, for sure.
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
19.1 Legacy Series
»
Monit setup to notify on connectivity change