Re: FreeBSD bootup service start issues

Bob Proulx <[email protected]> Tue, 28 Apr 2026 11:37:40 -0600
Newsgroups gmane.comp.monitoring.monit.general
Message-ID <[email protected]>
Marco Moock wrote:
> I am running monit from pkg ports on FreeBSD 15.
>
> I've set up various services for monitoring.

I think the original questions were answered by others.  But I must
make some comments.

> check process ntpd with pidfile /var/db/ntp/ntpd.pid
>         start program= "/usr/sbin/service ntpd start"
>         stop program= "/usr/sbin/service ntpd stop"
>         if 3 restarts within 5 cycles then unmonitor
>
> check process sendmail with pidfile /var/run/sendmail.pid
>         start program = "/usr/sbin/service sendmail start"
>         stop program = "/usr/sbin/service sendmail stop"
>         if 3 restarts within 5 cycles then unmonitor
>
> check process named with pidfile /var/run/named/pid
>         start program = "/usr/sbin/service named start"
>         stop program = "/usr/sbin/service named stop"
>         if 3 restarts within 5 cycles then unmonitor

These services are in the FreeBSD base set, are very mature, and in my
experience robust and never crash.  Monitoring these with monit is of
course fine but monit will never need to take action with these
processes.  Assuming robust hardware.

If you are experiencing crashes of these daemons then I strongly
suspect a hardware problem.  Perhaps failing ram.  Perhaps an
overheating system.  Something.  These are not processes normally
needing monitoring for recovery.

Another unfortunate possible problem is running too many processes on
a hardware system with too small of memory.  In which case the kernel
overcommit will initially hide the problem.  But eventually the kernel
will need to kill processes if there is not enough real memory.  In
which case one needs to reduce the memory use or add more RAM.  If
this is the problem then it should be logged in the /var/log/messages
system log file.  If it is memory shortage then any process on the
system is liable to be killed well beyond these three and that's going
to be a global problem needing to be resolved beyond simply restarting
these critical daemons.

If it is not a hardware problem then I would not be using monit on
these processes at all.  It's not needed.

I use monit on FreeBSD systems for monitoring and taking automated
action for things such as Apache becoming wedged up due to AI Scrapers
overloading it.  In which case I am monitoring the functionality and
restarting the jail container it is running within.  But this is due
to external influences.  And I use Nginx whenever possible which is
more resilient.

> I've also enabled those services in rc.conf, so the rc scripts will start
> them up

In addition to the excellent suggestions by the others it is also
valid to not have their service start in rc.conf and then allow monit
to control the start and stop of them.  Change to using "onestart" and
"onestop" instead of "start" and "stop" in that case.

I have done similar to this on systemd systems by not systemd enabling
the service and then simply having monit be the controller for it.
It's the same issues with systemd systems.

> When the OS boots up, monit notices that they are not running and tries to
> start them.

Another alternative is to avoid starting them multiple times but to
"restart" them.  Since restart will succeed in the case that it is
starting or restarting.

> This causes issues with ntpd and sendmail.

The issues you mention are errors in the log file?  Yes.  Those are
noisy and can hide actual problems.  Best to make the boot operate
cleanly.

Bob