Simple monitoring tool for your server – Munin tutorial

http://munin-monitoring.org/site/munin.pngNo need to explain how important is to monitor the performance of your server, it can help you understand which process is killing your server’s performance or even help to understand what’s going on when you don’t see any major slowdown (relay for spam? disk full? etc…) in an easy way through a Web Interface.

There are several tools to do that, such as Cacti, Munin, or more entreprise oriented softwares such as Nagios, Zenoss or even monitoring from 3rd party cloud service such as Zealion (Very fancy one with easy tools to dig into the records).

Most probably the easiest tool to use is Munin and you may have already seen some graphs from this tool:

http://blog.loftninjas.org/wp-content/uploads/2011/02/munin_stats-day.png

Sounds familiar?

So here is how to install it.

Installation

First of all, I assume you have a LAMP server working or similar. If you don’t have, please read my previous tutorial on how to install Apache with MySQL and PHP.

As most of similar tools, you can run the monitoring server on a different machine that you want to monitor, or attach several machines to main server.

If you have only in server, in root, simply run:

apt-get install munin

So now let’s see how to tweak a bit better the configuration by using a subdomain to access the stats, change server name, refresh time rate, adding a server to the pool, etc…

 

Configuration

Per default, munin store its html files in /var/cache/munin/web that you may want to change to /var/www/munin directly or create a subdomain to access directly to this folder.

I prefer to use the subdomain way to be able to access the graphs through munin.freedif.org

Here is my very simple virtualhost (Vhost):

<VirtualHost *:80>
        ServerAdmin webmaster@freedif.org
        ServerName munin.freedif.org

        DocumentRoot /var/cache/munin/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/cache/munin/www>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Once modified for your server, don’t forget to add a A redirection on your DNS server or registrar and to restart apache.

Also, munin will monitor locahost (127.0.0.1) under the name “localhost.localdomain”. You may want to change this value to better identify your servers among themselves too.

Still in root (su/sudo), type:

nano /etc/munin/munin.conf

and find the lines:

# a simple host tree
[localhost.localdomain]
    address 127.0.0.1
    use_node_name yes

then replace localhost.localdomain with the name you want. (Freedif in my case)

You can now save the file (CTRL +X) and restart munin node:

/etc/init.d/munin-node restart

By default, the graphs are refreshed every 5mn, if you want to decrease or increase this length, you can still modify the munin cron entry by modifying the file /etc/cron.d/munin.

 

Add a node

And if you want to monitor another machine, you need to install munin-node on this machine.

In root:

apt-get install munin-node

Next, you will need to edit the munin-node.conf file to specify your monitoring server IP to allow the connection.

Still in root:

nano /etc/munin/munin-node.conf

and find the line

<pre class="lang:default decode:true">allow ^127\.0\.0\.1$

to replace with your IP (Keep the same syntax)

and restart the node.

/etc/init.d/munin-node restart

Now on your monitoring server, you will need to modify /etc/munin/munin.conf to add your node.

nano /etc/munin/munin.conf

and after your initial host tree:

[Freedif.org]
    address 127.0.0.1
    use_node_name yes

And add your second host below:

[Mynewhost]
    address IP.IP.IP.IP
    use_node_name yes

After your modification done, you will need to restart apache. (in root)

/etc/init.d/apache2 restart

You should now have your 2 servers being monitored.

(Note that it should take 5min to see the update)

 

Gravatar

Loves to discover web-based apps to install on his own server@home and write articles about it

0 Comments:

Add a comment