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 :
1 2 3 4 5 6 7 8 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
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 :
1 2 3 4 5 6 7 8 9 10 |
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 :
1 |
# /etc/init.d/monit start |
Open the monit page and login using the cresidential you’ve created.
1 |
http://your.server.ip.address:2812 |
1 |
allow admin:test |