Wednesday, July 21, 2010

Getting Started With Munin - A Simple Setup

We have two machines; a server we want to monitor (serverA, IP: aaa.aaa.aaa.aaa) and a server which will monitor it (serverX, IP: xxx.xxx.xxx.xxx).


Setting up the node


On the server we want to monitor, we need to install munin-node.

serverA $ sudo apt-get install munin-node

By default, only serverA itself will be allowed to connect to this node to retrieve the data; we need to explicitly allow serverX to connect to it; this is done at the end of the configuration file of munin-node (usually in /etc/munin/munin-node.conf).

serverA $ sudo vi /etc/munin/munin-node.conf


You will find the following line:

allow ^127\.0\.0\.1$


Below, allow the IP adress of serverX to connect (the ^ and $ at the beginning and at the end are important):

allow ^xxx\.xxx\.xxx\.xxx$


As munin-node runs as a daemon, you need to restart it to make the changes active.

serverA $ sudo /etc/init.d/munin-node restart


Setting up the munin


On the monitoring server, we install munin:

serverX $ sudo apt-get install munin


We need to tell munin that we want it to monitor serverA. Munin's configuration munin.conf is usually to be found in /etc/munin/.

serverX $ sudo vi /etc/munin/munin.conf


At the end of the file, add the following:

[Domain;serverA]
address aaa.aaa.aaa.aaa
use_node_name yes


serverA should be the name of your machine. Domain is the "domain" of your machine; in fact it is more a group name, used to sort your servers. You can choose to sort by location (server1.edmonton...), by role (server1.apache), or whatever you feel is relevant. The usual notation I found everywhere is [serverA.domain]; I don't know why, as it creates a problem with domain names using dots, and makes the domain name appear after every node name in the overview page. I would recommend to use the notation I gave.

Munin is a Perl script run every 5 minutes by cron. The cronjob should have been set automatically during the installation. Therefore, you don't have to restart it; just wait 5 minutes.

Making the files accessible


Your files should already be available in /var/www/munin by now. Make them available by installing an HTTP server; lighttpd would do the job here.

serverX $ sudo apt-get install lighttp


You can then access the monitoring via your favorite browser with the address http://xxx.xxx.xxx.xxx/munin/.

Congratulations! Munin is working. Your server is now monitored, the default setup should be enough for most of the cases. But there is a lot of other cool stuff you can do with munin, which I will describe now :).

No comments:

Post a Comment