This how to are under construction please came back in a few days.


This howto describe how to install and monitoring and system with monit this howto base on Debian Etch.

1. Installation

apt-get install monit

2. Configure MONIT and backup the example config

cp /etc/monit/monitrc /etc/monit/monitrc_default
nano -w /etc/monit/monitrc

You have to replace hosting.example.com with your hostname

set daemon  60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: monit@hosting.example.com }
set alert root@localhost
set httpd port 2812 and
     SSL ENABLE
     PEMFILE  /etc/monit/monit.pem
     allow admin:ispcp

check system hosting.example.com
   if loadavg (1min) > 4 then alert
   if loadavg (5min) > 2 then alert
   if memory usage > 75% then alert
   if cpu usage (user) > 70% then alert
   if cpu usage (system) > 30% then alert
   if cpu usage (wait) > 20% then alert


# PROFTPD
check process proftpd with pidfile /var/run/proftpd.pid
   group services
   start program = "/etc/init.d/proftpd start"
   stop program  = "/etc/init.d/proftpd stop"
   if failed port 21 protocol ftp then restart
   if 5 restarts within 5 cycles then timeout

# SSHD
check process sshd with pidfile /var/run/sshd.pid
   group system
   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

# DNS SERVER
check process named with pidfile /var/run/bind/run/named.pid
   group services
   start program  "/etc/init.d/bind9 start"
   stop program  "/etc/init.d/bind9 stop"
   if failed host 127.0.0.1 port 53 type tcp protocol dns then alert
   if failed host 127.0.0.1 port 53 type udp protocol dns then alert
   if 5 restarts within 5 cycles then timeout

# MYSQL
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group services
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   if failed host 127.0.0.1 port 3306 then restart
   if 5 restarts within 5 cycles then timeout

# APACHE
check process apache with pidfile /var/run/apache2.pid
   group services
   start program = "/etc/init.d/apache2 start"
   stop program  = "/etc/init.d/apache2 stop"
   if failed host admin.hosting.example.com port 80 protocol http
      and request "/tools/monin_test_file" then restart
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 90% for 5 cycles then restart
   if totalmem > 500 MB for 5 cycles then restart
   if children > 250 then restart
   if loadavg(5min) greater than 10 for 8 cycles then stop
   if 3 restarts within 5 cycles then timeout

# POSTFIX
check process postfix with pidfile /var/spool/postfix/pid/master.pid
   group services
   start program = "/etc/init.d/postfix start"
   stop  program = "/etc/init.d/postfix stop"
   if failed port 25 protocol smtp then restart
   if 5 restarts within 5 cycles then timeout

# ISPCP_DAEMON
check process ispcp_daemon with pidfile /var/run/ispcp_daemon.pid
   group services
   start program = "/etc/init.d/ispcp_daemon start"
   stop  program = "/etc/init.d/ispcp_daemon stop"
# If you active this, your /var/log/daemon will grow every minute,
# so it's not recomended unless you don't want to trust only in .pid
#   if failed port 9876 then restart
   if 5 restarts within 5 cycles then timeout

3. Start Daemon

If this is a fresh install of monit on Debian then edit the following file

# vi /etc/default/monit

and make sure monit is turned on e.g.

startup=1

then (re)start the daemon

# /etc/init.d/monit start