Monit

Monit is a systems software watchdog. It will monitor services to make sure they are running, and take care of them if they get out of control.

Monitoring Modes

There are two ways for monit to operate: as active or passive. Active tries to fix problems while passive only monitors them, but sends alerts when something happens.

Init

For Gentoo / CentOS, add monit to /etc/inittab and run telinit q to start the process and keep it respawning upon death.

# monit
mo:2345:respawn:/usr/bin/monit -Ic /etc/monit/monitrc

Ubuntu

For Ubuntu, create /etc/init/monit.conf. Check the location of the monit binary, it may be in /usr/sbin instead of /usr/bin

start on runlevel [2345]
stop on runlevel [06]
exec /usr/bin/monit -Ic /etc/monit/monitrc
respawn

Add monit to the default runlevels:

update-rc.d monit defaults
service monit start

CentOS

Download and install the monit init.d script. Make sure that the MONIT variable in the script points to the correct binary.

Add monit to startup:

chkconfig --levels 235 monit on

FreeBSD

Add monit to startup:

echo monit_enable=YES >> /etc/rc.conf
/usr/local/etc/rc.d/monit start
Todo
  • Find out how to run monit all the time. See man 5 ttys for possible reference.

NetBSD

The following files should be created for monit-4.10.1nb2:

        /etc/rc.d/monit (m=0755)
            [/usr/pkg/share/examples/rc.d/monit]

Outgoing Email

Monit can be configured to use SocketLabs SMTP relay server to send outgoing email. SocketLabs only supports SSLv3 or no authentication:

set mailserver smtp.socketlabs.com username <username> password <password>
set mailserver smtp.socketlabs.com port 587 username <username> password <password> using SSLV3