2 min read

Installing Monit in Debian 6 32bit

I’m just having some idea for the usage of my vps rather than just for “blog” after reading some threads in the LET.
So, this time I want to write some tutorial about installing Monit in Debian6 32bit.

  • This is some easy installation for Monit :
Installing Monit :
# apt-get install monit
Creating a backup of monit control file :
# cp /etc/monit/monitrc /etc/monit/monitrc_orig
Replace the monit control file with and empty file :
# cat /dev/null > /etc/monit/monitrc
Editing the monit control file:
# nano /etc/monit/monitrc
  •  Configuring the Monit control file.Be sure to only put the check to the exist process, otherwise Monit won’t start.Copy paste the following text to the monitrc, and adjust it to your active process.
set daemon  60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: monit@server1.example.com }
set alert root@localhost
set httpd port 2812 and
     allow admin:test
check process proftpd with pidfile /var/run/proftpd.pid
   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
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
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   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
check process apache with pidfile /var/run/apache2.pid
   group www
   start program = "/etc/init.d/apache2 start"
   stop program  = "/etc/init.d/apache2 stop"
   if failed host www.example.com port 80 protocol http
      then restart
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 80% 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
check process postfix with pidfile /var/spool/postfix/pid/master.pid
   group mail
   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

 

  •  Enable the Monit init script :
nano /etc/default/monit
# Defaults for monit initscript
# sourced by /etc/init.d/monit
# installed at /etc/default/monit by maintainer scripts
# Fredrik Steen <stone@debian.org>
# You must set this variable to for monit to start
startup=1 <----- change from 0 to 1 to enable monit
# To change the intervals which monit should run uncomment
# and change this variable.
CHECK_INTERVALS=60 <----- add this line to make monit run every 60 seconds

 

  •  Start the monit :
# /etc/init.d/monit start

Open the monit page and login using the cresidential you’ve created.

http://your.server.ip.address:2812
allow admin:test

monit