Monit for monitoring Nginx and MariaDB on Debian8

Installing Monit

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install monit

Operating Monit

sudo nano /etc/monit/monitrc
sudo service monit start
sudo monit reload
sudo monit start all
sudo monit status

Configuration for local “monit status”

set httpd port 2812 and
 use address localhost
 allow localhost

Dont forget to open firewall port:

sudo ufw allow 2812

Configuration for MariaDB/Mysql

check process mysqld with pidfile /var/run/mysqld/mysqld.pid
 start program = "/etc/init.d/mysql start"
 stop program = "/etc/init.d/mysql stop"
# if cpu > 60% for 2 cycles then alert
# if cpu > 80% for 5 cycles then restart
 if totalmem > 256.0 MB for 5 cycles then restart
 if children > 100 then restart

Configuration for nginx

check process nginx with pidfile /var/run/nginx.pid
 start program = "/etc/init.d/nginx start"
 stop program = "/etc/init.d/nginx stop"
# if cpu > 60% for 2 cycles then alert
# if cpu > 80% for 5 cycles then restart
# if totalmem > 200.0 MB for 5 cycles then restart
 if children > 100 then restart
# if loadavg(5min) greater than 10 for 8 cycles then stop
# if failed host www.tildeslash.com port 80 protocol http
# and request "/somefile.html"
# then restart
 if failed port 443 type tcpssl protocol http
 with timeout 15 seconds
 then restart
 if 5 restarts within 5 cycles then timeout
 depends on mysqld
 group server

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s