[monitor]monit配置监控启动nginx php mysql redis mongodb 服务器

更新时间:2019-07-14    来源:MongoDB    手机版     字体:

【www.bbyears.com--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
  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

本文来源:http://www.bbyears.com/shujuku/58020.html

热门标签

更多>>

本类排行