Configure Monit

After installing Monit, you may want to use the web Interface. To access it you need to go to http://your.ip.address:2812 eg http://127.0.0.1:2812

If you have firewall installed, you are required to enable the 2812 port following rules below:-

Action : ACCEPT
Protocol : TCP
Port : 2812
IP address : 0.0.0.0/0
Comment (optional) : MONIT

To configure the auto restart or monitor of VestaCP services

First open the file monit config file using this command.

sudo nano /etc/monitrc

Some example of monitoring script, which should paste before the includes section:

set daemon 60
set logfile /var/log/monit.log
set logfile syslog facility log_daemon
set mailserver yourdomain.ru
set alert yourmail@gmail.com with mail-format {
from: monit@yourdomain.ru
subject: $SERVICE $EVENT at $DATE
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.

Solve this or this will be bad,
Your RobotAssistant
}

check filesystem hdddrive with path /
if space usage > 85% then alert
if inode usage > 80% then alert

check system yourdomain.ru
if loadavg (1min) > 15 then alert
if loadavg (5min) > 8 then alert
if memory usage > 85% then alert
if cpu usage (user) > 90% then alert
if cpu usage (system) > 90% then alert
if cpu usage (wait) > 80% then alert

check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid
start program = “/etc/init.d/vsftpd start”
stop program = “/etc/init.d/vsftpd stop”
if failed port 21 protocol ftp for 32 cycles then alert
if failed port 21 protocol ftp for 64 cycles then restart
if 15 restarts within 15 cycles then timeout

check process sshd with pidfile /var/run/sshd.pid
start program “/etc/init.d/ssh start”
stop program “/etc/init.d/ssh stop”
if failed port 22 protocol ssh for 15 cycles then alert
if failed port 22 protocol ssh for 15 cycles then restart
if 15 restarts within 15 cycles then timeout

check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = “/etc/init.d/mysql start”
stop program = “/etc/init.d/mysql stop”
if cpu > 80% for 10 cycles then restart
if failed host 127.0.0.1 port 3306 for 10 cycles then alert
if failed host 127.0.0.1 port 3306 for 10 cycles then restart
if 15 restarts within 15 cycles then timeout

check process nginx with pidfile /var/run/nginx.pid
start program “/etc/init.d/nginx start”
stop program “/etc/init.d/nginx stop”
if failed host yourdomain.ru port 80 protocol http for 6 cycles then alert
if failed host yourdomain.ru port 80 protocol http for 6 cycles then restart
if 15 restarts within 15 cycles then timeout

check process apache with pidfile /var/run/apache2.pid
start program = “/etc/init.d/apache2 start”
stop program = “/etc/init.d/apache2 stop”
if failed host yourdomain.ru port 8080 protocol http for 5 cycles then alert
if failed host yourdomain.ru port 8080 protocol http for 15 cycles then restart
if loadavg(5min) greater than 50 for 15 cycles then restart
if 15 restarts within 15 cycles then timeout

 

Leave A Comment?