Hi!请登陆

monit常用监控

2020-10-27 63 10/27

a.监控nginx

vi /etc/monit.d/nginx.monit
check process nginx with pidfile /usr/local/nginx/nginx.pid
start program = "/usr/local/nginx/sbin/nginx"
stop program = "/usr/local/nginx/sbin/nginx -s stop"
if failed host 192.168.1.11 port 8011 protocol http then restart

b.监控memcached

vi /etc/monit.d/memcached.monit
check process memcached with pidfile /tmp/linuxjcq_memcached.pid
start program = "/etc/rc.d/init.d/memcached start"
stop program = "/etc/rc.d/init.d/memcached stop"
if failed host 192.168.1.10 port 11211 protocol memcache then restart

c.监控php-fpm

vi /etc/monit.d/php-fpm.monit
check process php-fpm with pidfile /usr/local/php/logs/php-fpm.pid
start program = "/usr/local/php/sbin/php-fpm start"
stop program = "/usr/local/php/sbin/php-fpm stop"
if cpu > 50% for 2 cycles then alert
if cpu > 70% for 5 cycles then restart
if failed host 192.168.1.10 port 9000 then restart
if 5 restarts within 5 cycles then timeout

d.监控mysql

vi /etc/monit.d/mysqld.monit
check process mysqld with pidfile /data/mysql/mysql.pid
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 192.168.1.10 port 3306 then restart
if 5 restarts within 5 cycles then timeout 
Tag:

相关推荐