Does anybody know for both domain & subdirectory at the same time how to set up monit?

October 7, 2018 585 views
Monitoring Nginx Ubuntu 16.04

I have already setup monit for main domain(code below) but I am stuck for the subdirectory.

check process nginx with pidfile /var/run/nginx.pid
group www-data
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host example.com port 80 protocol http then restart
if 5 restarts within 5 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 failed unixsocket /var/run/mysqld/mysqld.sock then restart
       if 5 restarts within 5 cycles then timeout

   check process php7.0-fpm with pidfile /var/run/php7.0-fpm.pid
       start program = "/etc/init.d/php7.0-fpm start"
       stop program = "/etc/init.d/php7.0-fpm stop"
       if failed host example.com port 80 protocol http then restart
       if 5 restarts within 5 cycles then timeout
1 Answer

You need to use request like this:
if failed host example.com port 80 protocol http request "/blog" then alert

Have another answer? Share your knowledge.