using monit

한동안 개발이 중지되었던 monit가 돌아왔다. 모니터링 웹서버를 가지고 있고, 다양한 셋팅하에서의 자동 관리 기능이 있다.

case : ubuntu

apt-get install monit

case : centos

sudo yum install flex bison openssl-devel pam-devel
wget http://mmonit.com/monit/dist/monit-5.5.1.tar.gz
tar xvfz monit-5.5.1.tar.gz
cd monit-5.5.1
./configure
make
sudo make install

init script는 다음을 받아서 사용한다. monit.zip

wget http://yupmin.net/wp-content/uploads/2010/08/monit.zip
unzip monit.zip
sudo cp monit /etc/init.d
sudo chmod 755 /etc/init.d/monit
sudo touch /etc/monitrc
sudo chmod 700 /etc/monitrc
sudo vi /etc/monitrc

set daemon 60
set logfile syslog facility LOG_daemon
set mailserver localhost
set alert admin@abc.com
set httpd port 8080 address localhost
        allow localhost

check process apache with pidfile "/var/run/httpd.pid"
        start = "/etc/init.d/httpd start"
        stop = "/etc/init.d/httpd stop"
        if failed host 127.0.0.1 port 80 and protocol http
                and request "/abc.txt" then restart
        if cpu usage is greater than 60 percent for 2 cycles then alert
        if cpu usage > 98% for 5 cycles then restart
        if 2 restarts within 3 cycles then timeout
        alert admin@abc.com

check process mysql with pidfile "/var/run/mysqld/mysqld.pid"
        group database
        start program = "/etc/init.d/mysqld start"
        stop program = "/etc/init.d/mysqld stop"
        if failed host 127.0.0.1 port 3306 then restart
        if cpu usage > 98% for 5 cycles then restart
        if 5 restarts within 5 cycles then timeout