monit配置监控启动nginx php mysql redis mongodb 服务器
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-01 17:13:41 浏览: 评论:0
下面来看一个整理的monit配置监控启动nginx php mysql redis mongodb 服务器例子,我们这样监控之后可以保证服务器永不宕机,是不是非常的不错呀.
启动:monit -Ic /etc/monitrc &
crontab -e
*/600 * * * * /usr/local/bin/monit -Ic /etc/monitrc &
conf 配置:
- —————nginx php mysql redis mongodb 配置 完美OK——————–
- # nginx
- check process nginx with pidfile /usr/local/nginx/logs/nginx.pid
- start program = “/usr/local/nginx/sbin/nginx”
- stop program = “/usr/bin/killall nginx”
- if failed host 127.0.0.1 port 80 then restart
- if cpu is greater than 40% for 2 cycles then alert
- if cpu > 60% for 5 cycles then restart
- if 10 restarts within 10 cycles then timeout
- # php5-fpm
- check process php-fpm with pidfile /var/run/php-fpm.pid
- start program = “/usr/local/php5.3/sbin/php-fpm”
- stop program = “/usr/bin/killall php-fpm”
- if failed port 9000 then restart
- if cpu is greater than 40% for 2 cycles then alert
- if cpu > 60% for 5 cycles then restart
- if 10 restarts within 10 cycles then timeout# php5-fpm binary.
- check file php5-fpm-tcp_bin with path /usr/local/php5.3/sbin/php-fpm
- if 10 restarts within 10 cycles then timeout
- if failed checksum then unmonitor
- if failed permission 755 then unmonitor
- if failed uid root then unmonitor
- if failed gid root then unmonitor
- alert root@localhost# Test the init scripts.
- check file php5-fpm-tcp_init with path /usr/local/php5.3/sbin/php-fpm
- if failed checksum then unmonitor
- if failed permission 755 then unmonitor
- if failed uid root then unmonitor
- if failed gid root then unmonitor
- alert root@localhost
- # mysql
- check process mysql with pidfile /var/lib/mysql/localhost.localdomain.pid
- group database
- start program = “/sbin/service mysql start”
- stop program = “/sbin/service mysql stop”
- if failed port 8306 then restart
- if 3 restarts within 10 cycles then timeout
- # redis
- check process redis with pidfile /var/run/redis.pid
- start program = “/usr/local/redis/redis-server /usr/local/redis/redis.conf”
- stop program = “/usr/bin/killall redis-server”
- if failed host 127.0.0.1 port 6379 then restart
- if cpu is greater than 40% for 2 cycles then alert
- if cpu > 60% for 5 cycles then restart
- if 10 restarts within 10 cycles then timeout
- # mongodb
- check process mongod with pidfile /usr/local/mongodb/data/mongod.lock
- start program = “/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data/”
- stop program = “/usr/bin/killall mongod”
- if failed port 27017 protocol http and request “/” with timeout 10 seconds then restart
- if 10 restarts within 10 cycles then timeout
- —————-end——————-
- /usr/local/mmonit/bin/mmonit -c /usr/local/mmonit/conf/server.xml -t
- /usr/local/mmonit/bin/mmonit -c /usr/local/mmonit/conf/server.xml start
- monit -t
- killall monit
- monit -Ic /etc/monitrc &
- telinit q
- ps aux |grep monit
- kill -1 1
- ps aux |grep redis-server
- killall redis-server
- ll /var/run/redis.pid
- /usr/local/redis/redis-server /usr/local/redis/redis.conf &
- ps aux |grep php-fpm
- killall php-fpm
- /usr/local/php5.3/sbin/php-fpm
- ps aux |grep mongod
- killall mongod
- /usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data/ &
- set mmonit http://monit:monit@142.4.48.50:8080/collector
- set nginx port 80 and
- use address 142.4.48.50
- allow localhost
- allow 142.4.48.50
- http://mmonit.com/wiki/Monit/Nginx
- location /monit/ {
- rewrite ^/monit/(.*) /$1 break;
- proxy_ignore_client_abort on;
- proxy_pass http://192.168.1.10:2812;
- proxy_redirect http://192.168.1.10:2812/monit;
- }
- https://gist.github .com/franck
- # include /etc/monit.d/*
- # mysql
- check process mysqld with pidfile /var/lib/mysql/localhost.localdomain.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 8306 then restart
- if 5 restarts within 5 cycles then timeout
- # nginx
- check process nginx with pidfile /usr/local/nginx/logs/nginx.pid
- start program = “/usr/local/nginx/sbin/nginx”
- stop program = “/usr/bin/killall nginx”
- if failed host 127.0.0.1 port 80 then restart
- if cpu is greater than 40% for 2 cycles then alert
- if cpu > 60% for 5 cycles then restart
- if 10 restarts within 10 cycles then timeout
- # redis
- check process redis with pidfile /var/run/redis.pid
- start program = “/usr/local/redis/redis-server /usr/local/redis/redis.conf”
- stop program = “/usr/bin/killall redis-server”
- if 10 restarts within 10 cycles then timeout
- check file dump.rdb with path /usr/local/redis/dump.rdb
- if size > 100 MB then alert
- # php5-fpm
- check process php-fpm with pidfile /var/run/php-fpm.pid
- start program = “/usr/local/php5.3/sbin/php-fpm”
- stop program = “/usr/bin/killall php-fpm”
- if failed host 127.0.0.1 port 9000 then restart
- if cpu is greater than 40% for 2 cycles then alert
- if cpu > 60% for 5 cycles then restart
- if 10 restarts within 10 cycles then timeout
- # php5-fpm binary.
- check file php5-fpm-tcp_bin with path /usr/local/php5.3/sbin/php-fpm
- if 10 restarts within 10 cycles then timeout
- if failed checksum then unmonitor
- if failed permission 755 then unmonitor
- if failed uid root then unmonitor
- if failed gid root then unmonitor
- alert root@localhost
- # Test the init scripts.
- check file php5-fpm-tcp_init with path /usr/local/php5.3/sbin/php-fpm
- if failed checksum then unmonitor
- if failed permission 755 then unmonitor
- if failed uid root then unmonitor
- if failed gid root then unmonitor
- alert root@localhost
- # mysql
- check process mysqld with pidfile /var/lib/mysql/localhost.localdomain.pid
- group database
- start program = “/sbin/service mysql start”
- stop program = “/sbin/service mysql stop”
- if failed host 127.0.0.1 port 8306 then restart
- if 2 restarts within 6 cycles then timeout
- # mongodb
- check process mongod with pidfile /usr/local/mongodb/data/mongod.lock
- start program = “/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data/”
- stop program = “/usr/bin/killall mongod”
- if failed port 27017 protocol http and request “/” with timeout 10 seconds then restart
- if 10 restarts within 10 cycles then timeout
- #mongodb
- check process mongod with pidfile “/usr/local/mongodb/data/mongod.lock”
- start program = “/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data/”
- stop program = “/usr/bin/killall mongod”
- if failed port 27017 protocol http and request “/” with timeout 10 seconds then restart
- if 5 restarts within 5 cycles then timeout
- # tomcat
- check process tomcat with pidfile /var/run/tomcat/tomcat.pid
- start program = “/etc/init.d/tomcat start”
- as uid solr gid solr
- stop program = “/etc/init.d/tomcat stop”
- as uid solr gid solr //phpfensi.com
- if failed port 8080 then alert
- if failed port 8080 for 5 cycles then restart
- set mmonit http://monit:monit@142.4.48.50:8080/collector
- set httpd port 12112 and
- use address 142.4.48.50 //monit主机的IP
- allow localhost
- allow 142.4.48.50 //mmonit主机的IP
Tags: monit配置监控 nginx mongodb
相关文章
- ·linux中Nginx Rewrite规则工作笔记(2014-10-01)
- ·Linux中利用openssl生成SSL证书给nginx使用(2014-10-11)
- ·linux中编译Nginx支持Tcp_wrappers方法(2014-10-12)
- ·linux中修改Nginx For Tcp_wrappers返回444(2014-10-12)
- ·linux中配合php实现Nginx反向代理(2014-10-13)
- ·linux中Nginx的常用配置(域名跳转 https cdn配置)(2014-10-13)
- ·阿里云linux服务器配置安装nginx(2014-10-13)
- ·linux中Nginx与Lua执行顺序详解(2014-10-14)
- ·linux系统中Nginx守护进程(自动启动nginx)(2014-10-15)
- ·linux中nginx下禁止某目录执行php例子(2014-10-16)
- ·linux系统nginx php-fpm安装php memcache扩展(2014-10-17)
- ·Apache与Nginx登录认证配置详解(可认证目录)(2014-10-17)
- ·linux+nginx+php+mysql环境查找php.ini文件并修改(2014-10-18)
- ·Nginx下proxy_set_header 模块代码(2015-04-21)
- ·linux下Shell脚本分析Nginx日志抗小量ddos攻击(2015-04-21)
- ·linux下Nginx+Django Admin界面无样式问题解决方法(2015-04-21)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)