monit does not maintain state across reboots

Issue #447 closed
Gordon Cook created an issue

I turned some daemons off and unmonitored them

Monit 5.19.0 uptime: 23m
 Service Name                     Status                      Type          
 postie                           Not monitored               Process       
 demm                             Not monitored               Process       
 ct-hypervisor-daemon             Not monitored               Process       
 postie_log                       Not monitored               File          
 demm_log                         Not monitored               File          
 ct-hypervisor-daemon_log         Not monitored               File  

rebooted and all of them are back running and being monitored, this was not the case in 5.17.0

monitrc file below

$ cat /etc/monit/monitrc 
set daemon 60
     with start delay 120

set logfile syslog facility log_daemon                       

set statefile /var/lib/monit/monit.state
set idfile /var/lib/monit/monit.id
set pidfile /var/lib/monit/monit.pid

#set mmonit http://localhost/sys/monit_collector

set httpd port 2812 and
    use address 127.0.0.1  # only accept connection from localhost
    allow localhost        # allow localhost to connect to the server and
    allow admin:monit      # require user 'admin' with password 'monit

include /etc/monit/conf.d/*

Comments (7)

  1. Tildeslash repo owner

    The monit 5.18 introduced a new "onreboot" statement that sets a mode for starting services on reboot. The original behaviour was confusing for lot of users, so we decided to make the "onreboot start" the default mode.

    You can make the mode persistent this way:

    onreboot laststate
    

    Monit 5.18 changelog excerpt:

    New: A new ONREBOOT statement for service startup control on system reboot was added. The following
    modes are available:
        onreboot start     ... always start the service automatically after reboot (DEFAULT mode)
        onreboot nostart   ... never start the service automatically after reboot
        onreboot laststate ... the service state is persistent across reboot (stopped before reboot => stopped after reboot and vice versa)
    
  2. Gordon Cook reporter

    Hi again, quick check can you set a global * onreboot laststate seems to be each service dependent.

  3. Log in to comment