set daemon 120 check process sshd with pidfile /var/run/sshd.pid start program “/etc/init.d/sshd start” stop program “/etc/init.d/sshd 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/mysqld start” stop program = “/etc/init.d/mysqld stop” if failed host 127.0.0.1 port 3306 then restart if 5 restarts within 5 cycles then timeout check process nginx with pidfile /var/run/nginx.pid start program = “/etc/init.d/nginx start” stop program = “/etc/init.d/nginx stop” if failed host www.yanghengfei.com port 80 protocol http then restart check process php_cgi with pidfile /var/run/php_cgi.pid start program = “/etc/init.d/php_cgi start” stop program = “/etc/init.d/php_cgi stop” if failed host 127.0.0.1 port 9000 then restart if 5 restarts within 5 cycles then timeout check process apache with pidfile /var/run/httpd.pid group www start program = “/etc/init.d/httpd start” stop program = “/etc/init.d/httpd stop” if failed host www.yanghengfei.com port 8080 protocol http then restart if cpu is greater than 80% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 512 MB for 5 cycles then restart if children > 200 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if 3 restarts within 5 cycles then timeout
更多详细信息可以参考配置文件,里面注释写得很详细。
启动 monit 在 CentOS 下启动并加入到系统启动脚本:
复制代码
代码如下:
# /etc/init.d/monit start # /sbin/chkconfig monit on