• Home
  • Cloud
    • General
    • SaaS
    • BPaaS
    • PaaS
    • IaaS
    • Other Internet Hosted Applications
      • WordPress
        • WooThemes Canvas
          • WooThemes Canvas CSS
  • About me
  • Why Badly Wired?
  • Contact

Badly Wired

Connecting WordPress via APIs, Plugins and other stuff - a technical notebook

You are here: Home / Cloud / 5 minute guide to setup process monitoring with MONIT on Linux

5 minute guide to setup process monitoring with MONIT on Linux

30th August 2016 by Alan Leave a Comment

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

If you are running a VPS, for a production server, it is very useful to have a process that monitors, and restarts if failed, and notifies you of key processes, like apache, mysql, postfix & ssh.

Monit is a free open source tool that does the job.

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

Took me a little while to get my head around the setup, but it is actually very simple, one you know, and can be done in 5 minutes.

 

These are the step I take on Debian (should be the same for Ubuntu)

sudo apt-get install monit

You don’t need to start anything or add it to any startup files, it does that automatically

There are a few settings needed to allow notification, and email address, an email server and a httpd server so you can monitor. These are in /etc/monit/monitrc

sudo vim /etc/monit/monitrc

Find the comment line with the word mail server.  My mail-server is on MailGun and my server is on Google Cloud  Compute so uses port 2525.  (obviously change the myuser / mypasswd / mydomain )

set mailserver smtp.mailgun.org port 2525 
    username "myuser@mydomain.com" 
    password "mypasswd"

Find the comment line # set alert sysadm@foo.bar  and add the line

set alert myuser@mydomain.com

Find the comment # set httpd port 2812 and uncomment (remove the #) the first 3 lines so you get

set httpd port 2812 
   and use address localhost # only accept connection from localhost 
   allow localhost # allow localhost to connect to the server and

Save the file & then do a quick configuration test

sudo monit -t

if OK reload monit

sudo /etc/init.d/monit reload

and check the log (as any issues with mail server will show now )

sudo tail -f /var/log/monit.log

ctril-c to stop following the log

check the status, the following command should show just one ‘System’

sudo monit status

Now we add the services we want to monitor, for me that is apache, mysql, ssh and postfix  and these are all redefined in /etc/monit/monitrc.d  so we just need to copy the definitions into /etc/monit/conf.d   like so

cd /etc/monit/monitrc.d
sudo cp apache2 openssh-server mysql postfix ../conf.d

restart monit

sudo /etc/init.d/monit reload

check the status , the following should give you all the info

sudo monit status |more

And that is it, now if say mysql dies, it will be restarted and you will get an email

 

 

 

 

[Next] Find out where to host WordPress [Read the full article…]

Filed Under: Cloud, Code snippets, General, Google Cloud, Linux  Tagged: google compute engine, mailgun, monitoring

About Alan

I'm Alan from Fullworks Digital Ltd, where I develop WordPress Plugins and support and manage WordPress websites.

My day job consists of solving clients' WordPress issues and developing new code and solutions.

I started as a professional programmer in 1979 and had been involved with the IT of business technology in virtually every area that exist.

Badlywired.com is my personal blog and my aide memoire of the many interesting facts that I come across. As I spend a lot of time gathering parts of solutions from the internet and assembling them into my own solutions, and also just learning how to do things, this blog is primarily my 'note book' and a way of giving something back to the online community that has helped me extensively.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Applications
  • Cloud
    • General
    • Google Cloud
    • IaaS
    • Other Internet Hosted Applications
      • Wordpress
        • WooThemes Canvas
        • WooThemes Canvas CSS
    • SaaS
  • Code snippets
  • Discounts
  • Genesis
  • Google Apps for Works
  • Linux
  • News
  • SEO
  • Server setup
  • Services
  • Tech Tips
  • Uncategorised
  • Useful Images
  • Useful Stuff
  • WordPress Hosting
  • WordPress Plugins

Tags

background jobs beadcrumbs bind brandings Cache canvas Centos chrome css fail2ban Find firefox Flash fraud genesis gocardless godaddy Google google maps hackers internet explorer javascript KashFlow Linus linux Magento mapquest maps microsoft mysql news nohup php plugin plugins queens diamond jubilee replace SED SEO skype Varnish Virtualmin Webmin woothemes Wordpress

 

Affiliate and Privacy Notices

This site is free to use, but hopes to cover some costs through affiliate income, some products and links are affiliates and may earn the site advertising income.

Some affiliates use Cookies to track if you purchase from them, this allows them to apportion revenue to us you will need to refer to their specific privacy notices as to how you are tracked.

This site is a participant in the Amazon EU Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.co.uk.

  • Privacy Policy

Copyright © 2021 · Badly Wired