OPNsense Forum

English Forums => General Discussion => Topic started by: xpking on October 01, 2023, 07:42:41 AM

Title: Monit settings help
Post by: xpking on October 01, 2023, 07:42:41 AM
Dear all,

I would like to add a process checking for Crowdsec in opnsense.
If it fails then restart.
May I know how should I set this up?
Thank you.
Title: Re: Monit settings help
Post by: xpking on October 02, 2023, 04:01:47 AM
Oh...No one knows Monit?
Is there any other places that I can get help please?
Title: Re: Monit settings help
Post by: mimugmail on October 02, 2023, 06:18:40 AM
You add a Service test which checks for the relevant process. It should be easy if you know the path to it
Title: Re: Monit settings help
Post by: cookiemonster on October 02, 2023, 10:26:03 AM
seems to be in /var/run/crowdsec.pid
Title: Re: Monit settings help
Post by: xpking on October 02, 2023, 01:42:40 PM
Thank you both. :)
Could you please advise how to setup "Service Test settings"?
I don't know how to set condition.
Title: Re: Monit settings help
Post by: mimugmail on October 02, 2023, 03:04:00 PM
You add a Service Setting, Type Process, PID file is path to crowdsec and you add service crowdsec start to Start field .. I think it doesnt even need a Test or similar.
Title: Re: Monit settings help
Post by: xpking on October 03, 2023, 05:09:00 PM
Quote from: mimugmail on October 02, 2023, 03:04:00 PM
You add a Service Setting, Type Process, PID file is path to crowdsec and you add service crowdsec start to Start field .. I think it doesnt even need a Test or similar.
When I added this it showed me error.
"Should be a valid absolute path to the executable with its arguments."
Title: Re: Monit settings help
Post by: lilsense on October 05, 2023, 03:21:22 AM
Is there a good monit tutorial for OPNsense.
Title: Re: Monit settings help
Post by: mimugmail on October 05, 2023, 07:10:08 AM
Quote from: xpking on October 03, 2023, 05:09:00 PM
Quote from: mimugmail on October 02, 2023, 03:04:00 PM
You add a Service Setting, Type Process, PID file is path to crowdsec and you add service crowdsec start to Start field .. I think it doesnt even need a Test or similar.
When I added this it showed me error.
"Should be a valid absolute path to the executable with its arguments."

/usr/sbin/service ?
You can verify via CLI
Title: Re: Monit settings help
Post by: mimugmail on October 05, 2023, 07:10:52 AM
Quote from: lilsense on October 05, 2023, 03:21:22 AM
Is there a good monit tutorial for OPNsense.

No, in theory you can do anything with it. Just read the examples in the docs and play a bit
Title: Re: Monit settings help
Post by: breeze on March 09, 2024, 05:12:04 AM
With the help of the OPNsense documentation and chatgpt I was able to get Monit to monitor crowdsec:

Services -> Monit-> Settings -> Service Test Settings Tab -> Add (+)

Name: no_pid
Condition: does not exist
Action: Restart




Services -> Monit-> Settings -> Service Test Settings Tab -> Add (+)

Name: RestartLimit5
Condition: 5 restarts within 5 cycles
Action: Unmonitor




Services -> Monit-> Settings -> Service Settings Tab -> Add (+)

Enable service checks -> Check
Name: crowdsec
Type -> Process
Pid File: /var/run/crowdsec.pid
Start: /usr/local/etc/rc.d/crowdsec start
Stop: /usr/local/etc/rc.d/crowdsec stop
Tests -> no_pid,RestartLimit5
Depends -> Nothing Selected
Description: check to see if crowdsec is running

Note: Match can be left blank.

See screenshots below.
Title: Re: Monit settings help
Post by: mimugmail on March 09, 2024, 09:38:52 AM
Thx for sharing