Linux – How to restart “monit” when it stops or crashes

debianlinuxmonitprocess

I am setting up a server and have just installed "monit" to monitor processes and restart them (and alert me) when certain conditions are met. It works great.

My question is what happens when monit itself dies? Is there a correct way of ensuring that monit restarts itself when it dies? I currently have it restarting (even if it's already running) via a cron job but that doesn't seem very elegant.

What is considered the correct way to restart monit? I'm using Debian and installed it via apt-get (thus I have an /etc/init.d/monit script available). I have ensured it runs using the default levels using update-rc.d.

Thanks!

Best Answer

The Monit daemon doesn't really die.

Why do you assume it would?

Either way, the Monit service is managed by Puppet on my systems. But it's mainly to reload the service when I make configuration file changes.

  service { $monit_svc:
    ensure    => 'running',
    enable    => true,
    restart   => 'monit reload',
    subscribe => File[$monit_conf],
  }

While I don't advocate this, it is possible to run Monit from init. But the software is stable. This should not be necessary.