You'll need to ensure that the standard mailutils are installed on the server.
apt-get install postfix mailutils
Afterwards, modify the /etc/monit/monitrc
file by uncommenting the following lines to enable emailed notifications
set mailserver localhost #Use localhost for email delivery.
set mail-format {
from: monit@$HOST
subject: monit alert -- $EVENT $SERVICE
message: $EVENT Service $SERVICE
Date: $DATE
Action: $ACTION
Host: $HOST
Description: $DESCRIPTION
}
set alert [email protected] #Alert recipient
If you want to store notifications for dispatch, you'll need to enable the notifications queue.
set eventqueue
basedir /var/lib/monit/events # notifications store
slots 100 # limit the queue size
I don't need to be informed when the instance state has changed or reloaded, so I silence those alerts by uncommenting this instance
filter
## Do not alert when Monit starts, stops or performs a user initiated action.
set alert [email protected] not on {instance}
Make sure to comment out any include file directories at the end of /etc/monit/monitrc
. If a path is in the configuration file, but the file does not exist, monit will fail to start.
monit
monit reload
monit status
monit quit
monit -t
monit unmonitor all
monit monitor all
check directory marcfiles with path /home/admin/marc/
if changed timestamp then alert
check directory registeredusers with path /home/admin/users
if timestamp > 24 hour then alert
check file testalert with path /.nonexistent
alert [email protected] with reminder on 500 cycles
check filesystem rootfs with path /
if space usage > 90% then alert
check system example.com
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if swap usage > 25% then alert
if cpu usage (user) > 70% for 2 cycles then alert
if cpu usage (system) > 30% for 2 cycles then alert
if cpu usage (wait) > 20% for 2 cycles then alert
check host mmonit.com with address mmonit.com
if failed
port 443
with protocol https
and certificate valid > 30 days
use ssl options {verify: enable}
then alert
check process ezproxy with pidfile /var/run/ezproxy.pid
restart program = "/usr/local/ezproxy/ezproxy restart"
if failed port 80 protocol http for 2 cycles then restart
check file apache-error with path /var/log/apache2/error.log
if match "^timed out" then alert
check directory patrons with path /home/admin/patrons/
if changed timestamp then exec "/home/admin/scripts/process-patrons.py"