

To enable this option you need to change few lines in the main configuration file.īy default, Monit uses local host for sending emails. If you want to always have the latest updates on the monitored processes - just enable alerts and Monit will start sending emails to a specified address should any errors occur. The port address can also be changed to a custom one if security is a top priority. Of-course, this doesn’t mean that, you should not investigate the root cause of such crashes, but Monit will at-least help you keep your sanity while you are doing so.After the web interface has been configured it can be accessed by this link. Monit is a crucial tool for me to keep my websites and webapps running even when occasionally MySQL or some other service crashes. I manage multiple servers, most of which are running WordPress which I have configured on Nginx and MySQL. Or simply connect to your server on port 2812 to access the Web Interface.

You can check the status of Monit using the following command. You should have Monit running and monitoring all the configured programs. Sudo monit reload #in case monit was already started Once you are done with editing the configuration file, all that is left is to start Monit/reload configuration and start monitoring of all services via the following commands. Consult the Monit Documentation for full set of actions and checks possible. Note that, you can add additional check and actions for Apache too. Stop program = "/etc/init.d/apache2 stop" Start program = "/etc/init.d/apache2 start" check process apache with pidfile /run/apache2.pid Monit will restart Apache whenever it is unable to find Apache running.

Stop program = "/etc/init.d/nginx stop" Monitoring and Automatically restarting Apache with MonitĪdd the following lines in Monit configuration file, for enabling monitoring of Apache. Start program = "/etc/init.d/nginx start" check process nginx with pidfile /var/run/nginx.pid Monit will restart Nginx whenever it is unable to find a process for Nginx running. Monitoring and Automatically restarting Nginx with MonitĪdd the following lines in Monit configuration file, for enabling monitoring of Nginx. The above piece of configuration is sufficient to keep a watch on MySQL and restarting it in case of process termination. Note that, you can add additional action and checks which I am not showing here. Start program = "/etc/init.d/mysql start" check process mysqld with pidfile /var/run/mysqld/mysqld.pid Monit will restart MySQL whenever it is unable to find MySQL running. Monitoring and Automatically restarting MySQL with MonitĪdd the following lines in Monit configuration file, for enabling monitoring of MySQL. Make sure to enable port 2812 on your server. # use address localhost # only accept connection from localhost # allow localhost # allow localhost to connect to the server andĪllow username:password # require user 'username' with password 'password' # allow # allow users of group 'monit' to connect (rw) # allow readonly # allow users of group 'users' to connect readonly You can also decide to give Read-Write or Read Only permissions based on user groups. Additionally, we will set a username and password for the web interface. If you wish, you can change the default port at which Monit web interface will be accessible. To configure the web interface, find and uncomment the section that begins with set httpd port 2812. The first thing we will do is enable the Web Interface for Monit, so that we can access it from anywhere. Run the following command to open Monit configuration file in Vim editor: sudo vim /etc/monit/monitrc Enabling Web Interface I will show the very basic configurations required to enable the Monit Web interface and to monitor programs like MySQL, Nginx and Apache. We can install monit by simply running the following command sudo apt-get install monit Monit Web Interface Installing and Configuring Monit on Ubuntu
