Sentora Support Forums

Full Version: Monitoring running services and restart them if they stop working on Ubuntu.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To monitor running services and restart them if they stop working you can use Monit.

Here is the guide to install it:
https://www.digitalocean.com/community/t...gure-monit

But for a basic install run:

Code:
apt-get install monit

My setup:

Code:
nano /etc/monit/monitrc

And edit:

Code:
set httpd port 2812     use address 12.34.56.789 or monit.YourDomain.com # only accept connection from localhost     allow 0.0.0.0/0.0.0.0        # allow localhost to connect to the server and     allow admin:*password*      # require user 'admin' with password 'monit'

And add this to the bottom of the file.

Code:
#Apache Monitor check process apache with pidfile /var/run/apache2/apache2.pid     start program = "/etc/init.d/apache2 start" with timeout 60 seconds     stop program  = "/etc/init.d/apache2 stop"     if failed host YourDomain.com port 80 protocol http then restart #MySQL Monitor 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 failed unixsocket /run/mysqld/mysqld.sock then restart

Code:
service monit restart

Here is an example of Monit restarting Apache when it went down 7hrs ago.

[attachment=372]
I can not over state how well this has worked for me.