This tutorial is part of our ongoing series on CentOS 7 help and tutorials.

Monit is an open source monitoring tool. It has various monitoring functions of great value for ensuring your server stays online and at top performance.

All Monit processes can be monitored in your web browser. Another neat feature is that whenever maintenance or repair is required, Monit can initiate them automatically to make sure your systems are brought back online as soon as possible.

Monit is also used to manage files, programs directories, and even devices to check timestamp changes, size changes, checksum changes, TCP/IP change, protocol changes, etc.

Monit can:
– Check server status (offline/online)
– Check system load, RAM usage, SWAP
– Monitor disk, file size, partition, checksum, permission etc.
– Monitor hardware (hard disk, motherboard, etc) health
– Monitor sshd
– Monitor syslog

Let’s show you how to get it set up.

In this tutorial, we will be using a CentOS 7 server.

1. Download Monit
First of all you will have to download and mount the latest Monit package

2. Install Monit
Next, install Monit by typing the following:

3. Enable and start Monit
Next, we will have to enable and then start Monit.

# systemctl enable monit
# sytemctl start monit

4. Check status
Next, check Monit’s status with the following command

5. Configuring Monit
By default, Monit is configured to check a server every 30 seconds. We can alter this to any interval of time required. In the example below, I have set it to 60 seconds.

To open the Monit config file navigate to /etc/monit.conf

vi /etc/monitrc
set daemon 60

Now let’s setup Monit to work on port 2812:

First open the configuration file at /etc/monit.conf

vi /etc/monit.conf

Next, from the existing settings:

Change to:

Here, username is admin and password is monit. After you change to settings above, Monit will listen to port 2812. The admin user can access the web interface via any network.

Finally restart Monit to make changes effective:

# restart monit.service

Then, open your web browser and type in http://your-ip-address:2812 to access web interface.

6. Monitor Apache with Monit
We can also add other services to the monitoring system. As usual, the configuration file is located at /etc/monit.conf

Example of adding apache:

Then restart monit. You can then check monit’s summary by typing the command monit summary and you will see a process called ‘apache’ running.

7. Configure Monit for MySQL

Next, to add monitoring for your mySQL server to the system use the following commands:

Again restart Monit and check the summary:

Additionally, you can also configure monitoring for the sshd service.

Or add monitoring for syslog.

As always, reload Monit to make the changes effective

Do you need a new server to set this up? Get one of our cheap VPS plans today.

Facebooktwittergoogle_plusredditpinterestlinkedinmail