Setup monit on Ubuntu 14.04 with VestaCP #ubuntu #vestacp

Steven Brady June 4, 2015
0 people like this post

One of the things I’ve noticed VestaCP is sorely missing is automatic restarting of stopped services. Moreover, if you install VestaCP on a VPS with 1 GB RAM or less, MySQL will fail. A lot. So I setup monit to monitor and restart services. And, since I made each service its own configuration file, I thought I’d share to get anyone else up and running.

Install monit:

apt-get install monit

Super basic configuration:

nano /etc/monit/monitrc

Make sure you have a valid email on this line and make sure not commented out:

set alert your@email.com # receive all alerts

CTRL+O
CTRL+X

Put the appropriate files in /etc/monit/conf.d/ or just do the following:

cd /etc/monit/conf.d/
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/apache2.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/cron.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/dovecot.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/exim4.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/fail2ban.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/mysqld.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/nginx.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/sshd.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/vesta-nginx.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/14.04/vesta-php.conf

Of course, once you’ve copied these in you’ll want to reload monit:

monit reload

Hopefully that went without too much trouble.

Category: Geekery
  • 2
  • 258
Steven Brady

Steven is an intermediate Linux admin, aspiring Internet marketer, husband, uncle, Christian, and a fan of Linux, Android, and the Green Lantern.

Leave your comment

Comments (2 people commented this post)

  • avatar image

    Adam Newdow

    December 26, 2015 Reply
    Could be helpful to mention a few additional things. The httpd section of the monitrc file needs to be modified for the particular server, and also Vesta needs to have a firewall rule added. I manually added the port and rule to the firewall files, but I think you can do it via the admin panel. I was finally able to restart the firewall services, and then the rule showed up. Now I can finally access the monit GUI from my browser! Here's the vesta help page that finally allowed me to finish the processes I started here on your site, thank you for your help. https://forum.vestacp.com/viewtopic.php?t=6601
    • avatar image

      Steven Brady

      February 2, 2016 Reply
      Ah, good point. I don't use the monit web interface so it never occurred to me. I just set it up to restart services and I'm pretty happy with it that way. I'm glad you got it figured out and I'm glad this post helped you.