Table of Contents

Monit with Ubuntu 9.10

Website: mmonit.com

Problem

Monit won't start

Solution

Configuration

Example

monit.rc
#############################################################
##
# Email fuer Alerts
set daemon 120
set mailserver localhost
set mail-format {
   from: server@example.com
   subject: [$ACTION] $HOST $SERVICE $EVENT - monit
}
set alert admin@example.com
##
#############################################################
## fill level
##
## fill level boot-partition
check device bootfs with path /dev/sda1
    if space usage > 80% then alert
##
#############################################################
## Security Checks
##
## /etc
check directory etc with path /etc
  if changed timestamp then alert
#############################################################
## essential Services
##
## ssh
check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/ssh start"
   stop program  "/etc/init.d/ssh stop"
   if failed port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout
##
## cron
check process cron with pidfile /var/run/crond.pid
   alert admin@example.com only on { nonexist }
   group system
   start program = "/etc/init.d/cron start"
   stop  program = "/etc/init.d/cron stop"
   if 5 restarts within 5 cycles then timeout
##

More functions

Monit with webinterface

set httpd port 8080 and use address 192.168.1.100
 allow admin:password
set httpd port 2812 and
     SSL ENABLE
     PEMFILE  /var/certs/monit.pem
     allow admin:test

Check other Server

check host webserver.example.org with address webserver.example.org if failed port 80 protocol http for 5 cycles then alert
check host switch.example.org with address switch.example.org if failed icmp type echo count 5 with timeout 15 seconds then alert