
If failed host 0.0.0.0 port 80 then restart # NTP #Ĭheck process ntpd with pidfile /var/run/ntpd.pid Start program = “/etc/init.d/httpd start” If failed port 22 protocol ssh then restart # Webserver #Ĭheck process webserver with pidfile /var/run/httpd/httpd.pid
RELOAD MONIT CONFIG FILE HOW TO
Following are some useful configuration examples for monit, that can be very helpful to see how a service is running, where it keeps its pidfile and how to start and stop a service etc: # SSH # To do this, we will create separate files for every service located within the /etc/monit.d/ directory. Once the initial config is completed, we can configure some of the services we want to monitor.

Once you’ve configured it, you need to start the monit service to reload the new configuration settings: Use address localhost # only accept connection from localhostĪllow localhost # allow localhost to connect to the server andĪllow admin:monit # require user 'admin' with password 'monit'Īllow # allow users of group 'monit' to connect (rw)Īllow readonly # allow users of group 'users' to connect readonly sudo apt-get updateĪfter the installation is complete, edit the main config file to resemble the example below using your favorite text editor and set your own username and password: nano /etc/monit/monitrc set httpd port 2812 and # set the listening port to your desire. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

