Wednesday, June 16, 2010

Install and configure munin for Server Monitoring

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.X Server.

Step 1. Prepare Server machine. For quick installation and dependency resolution, you can install DAG repository:
# rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.elX.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/”

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
[localhost]
address 127.0.0.1
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 192.168.0.1 (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

[App_Server]
address 192.168.0.5
use_node_name yes

Here, App_Server is the name (you can write any), and 192.168.0.5 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.
Post a Comment