Quick Howto: Install and configure munin for Server Monitoring

by jagbir on April 30, 2008

Munin is an efficient and lightweight Monitoring tool. Its available in ‘server’ and ‘node’ packages. You can install server in a single machine and node in all other machines and then view all information/statistical data in server machine.

This quick copy and paste howto explains steps needed to setup server and multiple nodes. These steps are tested in CentOS 5 Server but Please check respective documentation to make sure this will work for you as well.

Step 1. Prepare Server machine. For quick installation and dependency resolution, you can install DAG repository:

$ rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Step 2. Install munin (server) and munin-node (node) on this machine:

$ yum install munin munin-node

Step 3. Setup a directory to store munin generated htmls, you can create a directory in your server DocumentRoot or in munin directory itself. Here we create it in munin’s directory:

$ cd /etc/munin
$ mkdir html
$ chown munin:munin html -R

Step 4. If in previous step, you created a directory in your web server root, then you dont need to set an alias, else if you did the exact whats written in above step, create an alias:

$ vi /etc/httpd/conf/httpd.conf
Alias /server-health/ "/etc/munin/html/"
<Directory "/etc/munin/html">
AllowOverride None
Options None
Order allow,deny
Allow from all

Step 5. Configure munin for monitoring localhost (you are already in /etc/munin directory):

$ vi munin.conf
htmldir /etc/munin/html
use_node_name yes

here we set the html directory and section for local machine. Feel free to change ‘localhost’ to any meaningful name like Monitoring Server etc. You can further read the file for more options.

Step 6. Start munin service:

$ chkconfig munin-node on
$ service munin-node start

Step 7. Restart your web server and then access the munin page from your browser by pointing it to http://localhost/server-health/. You can also password protect the munin page by using .htaccess or inserting rules in your httpd.conf file but its optional.

You should be able to view various parameters/values/trends related to disk,network,apache,mail etc of your local machine/server via browser. Let us configure multiple nodes now:

Step 8. SSH to any other machine/ server and install DAG repository as described in Step 1 and then install the munin node:

$ yum install munin-node

Step 10. Configure the node to allow our main server get input from this machine. For this purpose, we need to add ‘Allow IP ADDRESS’ line in config file. Note that there’s already a Allow line which allow localhost to get values, we just need to add another line for server:

$ vi /etc/munin/munin-node.conf
allow ^192\.168\.0\.1$

Here (change it as per your settings) is the IP of server machine, written in regex form which is required here.

Step 11. Start the node now:

$  chkconfig munin-node on
$ service munin-node start

Now configure the Server to monitor the above machine:

Step 12. Goto Server machine and update munin.conf and add a new section:

$  vi /etc/munin.conf
use_node_name yes

Here, App_Server is the name (you can write any), and is the IP address of the machine in which we configured munin-node in Step 9 to Step 11.

After a while, Check you browser and munin should include the update from node machine.

Common Issues:

1. No values/stats are displayed or blank.
Please verify that munin-node service is running at machine. Verify it by telnet from machine itself:

$ telnet localhost 4949

You should see munin prompt here, write fetch cpu and press ENTER. You should see various values related to your cpu. If you are not able to telnet to port 4949 (munin port) then possibly munin-node is not running or your iptable (firewall) or SELinux policy is preventing its usage.

After checking from localhost, go to Server machine and try to telnet from there:

$ telnet 4949

You should get munin prompt and see values after issuing fetch cpu command there. If not, then firewall/selinux is preventing access this port or you didnt allowed this server from your munin-node.conf to get updates.

2. Why not compile from source?
Thats the best idea but when I tried the same, I got lots of perl modules dependencies/compile errors. Though, I managed to get its working but for a quick setup, yum is your friend.

3. I do not need all these values coming in graphs.
You can remove any plugin for which you do not want graph. Plugins are stored in /etc/munin/plugins directory and configured in plugins.conf. Configure these as per your requirements.

You may also like to read:
* 5 steps to secure your Linux Server
* Ensuring secure access to production Linux Servers
* Bash script to backup essential log files in Linux
* Quickly change your ssh port from defualt 22 to something higher
* SSH port forwarding from remote to local machine
* Save root or user history to check later
* Install and configure denyhost to prevent brute force attacks

  • http://linuxarea.webs.com sandeeprhce5

    I appreciate this tutorial thanks. No i have something new for learn.

  • red dragon

    Thanks! It was the connection between the client and server that got me. Editing munin-node.conf on each of the client servers was required and all it needed was adding an extra address to point to the munin “master” server.

  • http://www.3rbsc.com/vb/ 3rbsc.com

    good topic

  • Musa

    It seems to be yet another great post by the admin :)
    since i am using Ubuntu 10.04 and this is for CentOS, i cant find httpd directory in /etc.
    any substitute for the same?
    Also, can we install munin on windows OS? and, will the server on which we install munin-server, be able to monitor itself?

    Eagerly waiting for your kind help as ever :)


  • http://linuxadminzone.com jagbir

    Apache usually store its config file under /etc/apache2 in ubuntu.

    though I have MCP (Microsoft Certified Professional) but I hate discussing Windows and never tried Munin running on it.

  • http://www.3blog.info/2011/07/28/swiss-watches-all-brands/ Esq Swiss Watches For Men

    Excellent work just as before, but I can’t believe I agree with your last point.

  • http://decorativepillow.org bed throw pillows

    Can i upload short excerpts of copyrighted content on youtube?Is it supported by fair use provision?

  • oso_togari

    very useful to start

    thx a lot

  • Pingback: przglądarka firefox

Previous post:

Next post: