Monit Installation and Configuration

Monit is an opensource software for monitoring. Monit can monitor background processes, filesystems and file permissions as well as system devices. Monit has the ability to do these all tasks without taking too much CPU time or memory.

Note:- Text in bold letters denotes either a command or some configuration.

Downloading Source:

As I have installed FEDORA 10 from live CD, so minimum packages are installed. First of all install wget by.

#yum install wget

After installation of wget, download the source tar ball by.


Monit Dependencies

Below are the decencies if you are trying to install via source tar ball.

  1. gcc (yum install gcc)
  2. flex (yum install flex)
  3. bison (yum install bison)
  4. openssl and openssl-devel (yum install openssl openssl-devel)

And you’re done with decencies.

As I am installing monit via yum so I do not need these dependencies, as yum will handle these by itself.


For yum based install just do the following.

#yum install monit

Source based install execute below three commands.

  1. ./configure
  2. make
  3. make install

You are done with installation of monit.

Configuring Monit

The configuration file of monit in Fedora or RedHat is /etc/monit.conf and in debian based system /etc/monit/monitrc.

If you open this file all the lines in this files will be commented so we should enable only one directive here which includes /etc/monit.d/*

Then put all the configurations by creating another file on the path /etc/monit.d/.

We will create /etc/monit.d/monitconf/ and start configuration there.

Open the file and start configuring it.

1) set daemon 20

Set daemon directive tells monit, the interval to check daemon, files, directories etc. after. We set it to 20. So after 20 seconds it will check the daemons for monitoring. Default time is 120 seconds.

2) set logfile syslog

In this directive we are telling monit to log things to syslog.

3) set mailserver “” port “587”
username password “password”
using tlsv1
with timeout 30 seconds
set alert

In the above snippet we defined the email alerts. So, when a daemon or file or directory is not running or there is some permission problem it will send an email to using SMTP  from after 30 seconds.

4) set httpd port 2812 and
use address localhost
allow localhost
alow toqi:monit

Monit also has web features so you can enable it by the above code. Monit will listen for requests on port “2812” and will allow only localhost and

So if someone writes web URL other then localhost:2812 and 192.168… it will be denied. You can access monit interface with username “toqi” and password “monit”.

Basic configuration of monit has been completed. Now you can add some extra configuration to monitor your specific services and system.

To check your configuration.

#monit –t

Access the web via http://localhost:2812, enter your username toqi and password monit.

For the sake of illustration, I will add some configuration to monitor system and httpd service.

Now add the following in your configuration file.

If loadavg (1min) > 4 then alert
If loadavg (5min) > 2 then alert
If memory usage > 75% then alert
If cpu usage (user) > 20% then alert

check process httpd with pidfile = /usr/tun/
group www
start program = “/etc/init.d/httpd start”
stop program = “/etc/init.d/httpd stop”
if children > 250 then restart
if loadavg (5min) greater then 10 for 8 cycles then stop
if 3 restart without 5 cycles then timeout

Above snippets are self explained. These are all the conditions in which monit will send an alert to the administrator of the system. Now restart the service of monit via “service monit restart” and check with the webinterface you will get some info about http.

If you have any questions about monit please ask.

Good Luck

One thought on “Monit Installation and Configuration

  1. yogi

    spelling mistakes left right and centre. esp code. but good work!

Leave a Reply

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