monit配置监控启动nginx php mysql redis mongodb 服务器
2019/10/10/17:47:16 阅读:1841 来源:谷歌SEO算法 标签:
SEO教程
下面来看一个整理的monit配置监控启动nginx php mysql redis mongodb 服务器例子,我们这样监控之后可以保证服务器永不宕机,是不是非常的不错呀.
启动:monit -Ic /etc/monitrc &
crontab -e
*/600 * * * * /usr/local/bin/monit -Ic /etc/monitrc &
conf 配置:
- —————nginxphpmysqlredismongodb配置完美OK——————–
- #nginx
- checkprocessnginxwithpidfile/usr/local/nginx/logs/nginx.pid
- startprogram=“/usr/local/nginx/sbin/nginx”
- stopprogram=“/usr/bin/killallnginx”
- iffailedhost127.0.0.1port80thenrestart
- ifcpuisgreaterthan40%for2cyclesthenalert
- ifcpu>60%for5cyclesthenrestart
- if10restartswithin10cyclesthentimeout
- #php5-fpm
- checkprocessphp-fpmwithpidfile/var/run/php-fpm.pid
- startprogram=“/usr/local/php5.3/sbin/php-fpm”
- stopprogram=“/usr/bin/killallphp-fpm”
- iffailedport9000thenrestart
- ifcpuisgreaterthan40%for2cyclesthenalert
- ifcpu>60%for5cyclesthenrestart
- if10restartswithin10cyclesthentimeout#php5-fpmbinary.
- checkfilephp5-fpm-tcp_binwithpath/usr/local/php5.3/sbin/php-fpm
- if10restartswithin10cyclesthentimeout
- iffailedchecksumthenunmonitor
- iffailedpermission755thenunmonitor
- iffaileduidrootthenunmonitor
- iffailedgidrootthenunmonitor
- alertroot@localhost#Testtheinitscripts.
- checkfilephp5-fpm-tcp_initwithpath/usr/local/php5.3/sbin/php-fpm
- iffailedchecksumthenunmonitor
- iffailedpermission755thenunmonitor
- iffaileduidrootthenunmonitor
- iffailedgidrootthenunmonitor
- alertroot@localhost
- #mysql
- checkprocessmysqlwithpidfile/var/lib/mysql/localhost.localdomain.pid
- groupdatabase
- startprogram=“/sbin/servicemysqlstart”
- stopprogram=“/sbin/servicemysqlstop”
- iffailedport8306thenrestart
- if3restartswithin10cyclesthentimeout
- #redis
- checkprocessrediswithpidfile/var/run/redis.pid
- startprogram=“/usr/local/redis/redis-server/usr/local/redis/redis.conf”
- stopprogram=“/usr/bin/killallredis-server”
- iffailedhost127.0.0.1port6379thenrestart
- ifcpuisgreaterthan40%for2cyclesthenalert
- ifcpu>60%for5cyclesthenrestart
- if10restartswithin10cyclesthentimeout
- #mongodb
- checkprocessmongodwithpidfile/usr/local/mongodb/data/mongod.lock
- startprogram=“/usr/local/mongodb/bin/mongod–dbpath=/usr/local/mongodb/data/”
- stopprogram=“/usr/bin/killallmongod”
- iffailedport27017protocolhttpandrequest“/”withtimeout10secondsthenrestart
- if10restartswithin10cyclesthentimeout
- —————-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.xmlstart
- monit-t
- killallmonit
- monit-Ic/etc/monitrc&
- telinitq
- psaux|grepmonit
- kill-11
- psaux|grepredis-server
- killallredis-server
- ll/var/run/redis.pid
- /usr/local/redis/redis-server/usr/local/redis/redis.conf&
- psaux|grepphp-fpm
- killallphp-fpm
- /usr/local/php5.3/sbin/php-fpm
- psaux|grepmongod
- killallmongod
- /usr/local/mongodb/bin/mongod–dbpath=/usr/local/mongodb/data/&
- setmmonithttp://monit:monit@142.4.48.50:8080/collector
- setnginxport80and
- useaddress142.4.48.50
- allowlocalhost
- allow142.4.48.50
- http://mmonit.com/wiki/Monit/Nginx
- location/monit/{
- rewrite^/monit/(.*)/$1break;
- proxy_ignore_client_aborton;
- proxy_passhttp://192.168.1.10:2812;
- proxy_redirecthttp://192.168.1.10:2812/monit;
- }
- https://gist.github.com/franck
- #include/etc/monit.d/*
- #mysql
- checkprocessmysqldwithpidfile/var/lib/mysql/localhost.localdomain.pid
- groupdatabase
- startprogram=“/etc/init.d/mysqlstart”
- stopprogram=“/etc/init.d/mysqlstop”
- iffailedhost127.0.0.1port8306thenrestart
- if5restartswithin5cyclesthentimeout
- #nginx
- checkprocessnginxwithpidfile/usr/local/nginx/logs/nginx.pid
- startprogram=“/usr/local/nginx/sbin/nginx”
- stopprogram=“/usr/bin/killallnginx”
- iffailedhost127.0.0.1port80thenrestart
- ifcpuisgreaterthan40%for2cyclesthenalert
- ifcpu>60%for5cyclesthenrestart
- if10restartswithin10cyclesthentimeout
- #redis
- checkprocessrediswithpidfile/var/run/redis.pid
- startprogram=“/usr/local/redis/redis-server/usr/local/redis/redis.conf”
- stopprogram=“/usr/bin/killallredis-server”
- if10restartswithin10cyclesthentimeout
- checkfiledump.rdbwithpath/usr/local/redis/dump.rdb
- ifsize>100MBthenalert
- #php5-fpm
- checkprocessphp-fpmwithpidfile/var/run/php-fpm.pid
- startprogram=“/usr/local/php5.3/sbin/php-fpm”
- stopprogram=“/usr/bin/killallphp-fpm”
- iffailedhost127.0.0.1port9000thenrestart
- ifcpuisgreaterthan40%for2cyclesthenalert
- ifcpu>60%for5cyclesthenrestart
- if10restartswithin10cyclesthentimeout
- #php5-fpmbinary.
- checkfilephp5-fpm-tcp_binwithpath/usr/local/php5.3/sbin/php-fpm
- if10restartswithin10cyclesthentimeout
- iffailedchecksumthenunmonitor
- iffailedpermission755thenunmonitor
- iffaileduidrootthenunmonitor
- iffailedgidrootthenunmonitor
- alertroot@localhost
- #Testtheinitscripts.
- checkfilephp5-fpm-tcp_initwithpath/usr/local/php5.3/sbin/php-fpm
- iffailedchecksumthenunmonitor
- iffailedpermission755thenunmonitor
- iffaileduidrootthenunmonitor
- iffailedgidrootthenunmonitor
- alertroot@localhost
- #mysql
- checkprocessmysqldwithpidfile/var/lib/mysql/localhost.localdomain.pid
- groupdatabase
- startprogram=“/sbin/servicemysqlstart”
- stopprogram=“/sbin/servicemysqlstop”
- iffailedhost127.0.0.1port8306thenrestart
- if2restartswithin6cyclesthentimeout
- #mongodb
- checkprocessmongodwithpidfile/usr/local/mongodb/data/mongod.lock
- startprogram=“/usr/local/mongodb/bin/mongod–dbpath=/usr/local/mongodb/data/”
- stopprogram=“/usr/bin/killallmongod”
- iffailedport27017protocolhttpandrequest“/”withtimeout10secondsthenrestart
- if10restartswithin10cyclesthentimeout
- #mongodb
- checkprocessmongodwithpidfile“/usr/local/mongodb/data/mongod.lock”
- startprogram=“/usr/local/mongodb/bin/mongod–dbpath=/usr/local/mongodb/data/”
- stopprogram=“/usr/bin/killallmongod”
- iffailedport27017protocolhttpandrequest“/”withtimeout10secondsthenrestart
- if5restartswithin5cyclesthentimeout
- #tomcat
- checkprocesstomcatwithpidfile/var/run/tomcat/tomcat.pid
- startprogram=“/etc/init.d/tomcatstart”
- asuidsolrgidsolr
- stopprogram=“/etc/init.d/tomcatstop”
- asuidsolrgidsolr//phpfensi.com
- iffailedport8080thenalert
- iffailedport8080for5cyclesthenrestart
- setmmonithttp://monit:monit@142.4.48.50:8080/collector
- sethttpdport12112and
- useaddress142.4.48.50//monit主机的IP
- allowlocalhost
- allow142.4.48.50//mmonit主机的IP
热门评论