Installation
emerge app-admin/monit
Configuration
Save default config file:
mv /etc/monitrc /etc/monitrc.dist
/etc/monitrc:
# each cycle is 1 minute, wait for 2 minutes before starting monitoring to be sure that all services are up.
set daemon 60 with start delay 120
# if we will use integrated monit ssl validation then we need normal validation because by default will not check ssl certificates
set ssl {
verify : enable,
selfsigned : reject
}
# defaults
set logfile syslog
set pidfile /var/run/monit.pid
set idfile /var/lib/monit.id
set statefile /var/lib/monit.state
# example how to auth through google mail to send emails
set mailserver smtp.gmail.com port 587 from_username "from_username@gmail.com" password "secret" using TLSV1
# who will receive message and when
set alert to_username@gmail.com not on { instance, action } with reminder on 180 cycles
# set message format
set mail-format {
from: from_username@gmail.com
reply-to: to_username@gmail.com
subject: Monit $HOST: $SERVICE ~ $EVENT -> $ACTION
message: Monit $HOST: $SERVICE ~ $EVENT -> $ACTION
$DESCRIPTION
$DATE
}
# run monit status web service on localhost only
set httpd port 2812 and
use address localhost
allow localhost
# include custom rules
include /etc/monit.d/*
rc-update add monit default
/etc/init.d/monit start
When you will update some configs:
/etc/init.d/monit reload
When you need to check status:
monit status
Please refer for monit documentation how to setup custom monitoring rules.