Monitoring Servers and Clients using Munin in Ubuntu

Sponsored Link
"Munin" means "memory".Munin the tool surveys all your computers and remembers what it saw. It presents all the information in in graphs through a web interface. Its emphasis is on plug and play capabilities. After completing a installation a high number of monitoring plugins will be playing with no more effort. Using Munin you can easily monitor the performance of your computers, networks, SANs, and quite possibly applications as well. It makes it easy to determine "what's different today" when a performance problem crops up. It makes it easy to see how you're doing capacity wise on all limited resources.

It uses the excellent RRDTool and is written in Perl. Munin has a master/node architecture in which the master connects to all the nodes at regular intervals and asks them for sdata. It then stores the data in RRD files, and (if needed) updates the graphs. One of the main goals has been ease of creating new plugins (graphs).

Preparing Your System

You need to install apache web server using the following command

sudo apt-get install apache2

Munin contains two parts for it's configuration

munin (munin server) -- the part that creates the monitoring graphs

munin-node (munin Client) -- the munin client program.

Install Munin Server and client in Ubuntu

If you want to install munin server and munin client you need to install munin and munin-node packages using the following command

sudo apt-get install munin munin-node

Munin File Structure

This will install munin in /etc/munin directory this includes the following files

munin.conf munin-node.conf plugin-conf.d plugins templates

This will install files for webserver root directory in /var/www/munin directory this includes the following files

definitions.html index.html localdomain logo.png style.css

Munin Configuration

If you want to configure munin server you need to edit the /etc/munin/munin.conf file.The sample file looks like below.

sudo vi /etc/munin/munin.conf

-Start File-

# Example configuration file for Munin, generated by ‘make build'

# The next three variables specifies where the location of the RRD
# databases, the HTML output, and the logs, severally. They all
# must be writable by the user running munin-cron.

dbdir /var/lib/munin
htmldir /var/www/munin
logdir /var/log/munin
rundir /var/run/munin

# Where to look for the HTML templates
tmpldir /etc/munin/templates

# Make graphs show values per minute instead of per second
#graph_period minute

# Drop [email protected] and [email protected] an email everytime
# something changes (OK -> WARNING, CRITICAL -> OK, etc)
#contact.someuser.command mail -s "Munin notification" [email protected]
#contact.anotheruser.command mail -s "Munin notification" [email protected]
#
# For those with Nagios, the following might come in handy. In addition,
# the services must be defined in the Nagios server as well.
#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg

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

-End File --

In this above sample config file we need to look maily these files

dbdir /var/lib/munin
htmldir /var/www/munin
logdir /var/log/munin
rundir /var/run/munin

If you want to change any of the paths you need to change here.The one thing you might want to change is htmldir option
where you can change for you clients name or any other name suitable for you

Most Important thing is adding clients machines to munin.conf file for this you can see by default

localhost.localdomain is added under a simple host tree that looks like this

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

Now server side configuration ready.Now we are going see munin clients configuration

Munin Clients Configuration in Ubuntu

If you want to monitor any number of client machines using munin you need to install munin-node package in all your clients machines

Installing munin Client in Ubuntu

If you want to install munin client in your machine you need to enter the following command

sudo apt-get install munin-node

This will install munin node package and it will create a folder called /etc/munin.

Munin-node File Structure

this contains the following files

munin-node.conf plugin-conf.d plugins

munin-node.conf -- Client Configuration File

plugin-conf.d -- Configuration of plugins for this node

plugins -- A directory in which each file is a symlink to a real plugin in /usr/share/munin/plugins

Configuring Munin Node

Now you need to configure the munin-node.conf file

Configuration file looks like this and in this file i have entered some examples also

-- start file --

#
# Example config-file for munin-node
#

log_level 4
log_file /var/log/munin/munin-node.log
port 4949
pid_file /var/run/munin/munin-node.pid
background 1
setseid 1

# Which port to bind to;
host *
user root
group root
setsid yes

# Regexps for files to ignore

ignore_file ~$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$

# Set this if the client doesn't report the correct hostname when
# telnetting to localhost, port 4949
#
#host_name localhost.localdomain

host_name munintest.test.com

# A list of addresses that are allowed to connect. This must be a
# regular expression, due to brain damage in Net::Server, which
# doesn't understand CIDR-style network notation. You may repeat
# the allow line as many times as you'd like

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

allow ^172\.30\.5\.132$

In the above configuration file there are two important things you need to enter first one is under
#host_name localhost.localdomain you need to add your client machine fully qualified name example

#host_name localhost.localdomain

host_name munintest.test.com

Second one is you need to enter the server ipaddress by defauly you can see 127.0.0.1 in your config file under that

you need to add your munin server ipaddress example as follows

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

allow ^172\.30\.5\.132$

-- End File --

Adding Munin Plugins

If you want to install munin plugins you need to check the available plugins from here

Now you need to add plugins for for your client machine to monitor the required services for this edit the file located

at /etc/munin/plugin-conf.d/munin-node sample file looks like below

-- Start File --

# This file is used to configure how the plugins are invoked.
#
# user # Set the user to run the plugin as.
# group # Set the group to run the plugin as.
# command # Run instead of the plugin. %c expands to
# what would normally be run.
# env. # Sets in the plugin's environment, see the
# individual plugins to find out which variables they
# care about.

[apt]
user root

[cps*]
user root

[fw_conntrack]
user root

[hddtemp_smartctl]
user root

[if_*]
user root

[if_err_*]
user nobody

-- End File --

Now you need to add the user,group,command,env. and plugin name

Now look in to plugins/ directory it is a directory in which each file is a symlink to a real plugin in /usr/share/munin/plugins.Any plugin linked in here will be checked for and displayed in the resulting web pages.Add the plugins you want (e.g. if running exim4 then I'd add postfix_queue and postfix_stats).You'll need to set user/group rights in the munin-node conf file.

Most plugins can be run from the command line with the autoconf param to check if they can run -- e.g.

./postfix_stats autoconf yes

You can add any plugins you want to monitor and default plugins are located at /etc/munin/plugins directory

Finally you need to restart your munin service for your client machine after configuring any plugins

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

That's it from client side configuration

Finally important step you need to do in your munin server config file that is located in your munin server machine

/etc/munin/munin.conf

You need to add all your client machines list under this

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

example:-

# a simple host tree
[localhost.localdomain]
address 127.0.0.1
use_node_name yes
[munintest.test.com] -- this is our test client we have mentioned earlier
address 172.30.5.129
use_node_name yes

After entering all the client machine details you need to the following command to take the effect of our new changes effect.

sudo /usr/share/munin/munin-update --force-root

Testing Your Munin Installation

Now you need to go to http://your-server-ip/munin/ you should see the following screen if you have more no.of clients it should show those clients also

Once you click on Localdomain (which means localhost) you should see the following screen with list of currently monitoring graphs

If you want to see the graphs you need to wait for some time this is automaticalling done by munin.Munin sets up a cron job via the file /etc/cron.d/munin which will run /usr/bin/munin-cron.Running this file will poll each of the nodes -- and then will create the graphs in /var/www/html

Keeping an eye on these graphs will help you to keep your servers running healthily -- and can give advance warning of problems to come.

If you want to protect munin output directory (default /var/www/munin) you can use htaccess file for this and give access only for required users

Troubleshooting Munin

If you have any problems you need to check the log files of munin located at /var/log/munin directory

On server side Important log files are

munin-node.log -- should show the connections that are occuring.

munin-graph.log -- should show info on the services being graphed.

munin-html.log -- should show info on the html being generated.

On Client side important log files are

munin-node.log -- should show the connections that are occuring

Munin Sample Graphs

Here is the some of the sample Graphs i have got from my server machine these graphs are for one day it will show by weekly,by monthly and by Yearly Graphs also

CPU Usage -- By Day

Load Average -- By Day

Memory Usage -- By Day

No.Of Processes Running -- By Day

Sponsored Link

You may also like...

9 Responses

  1. Phill says:

    Hi there,

    I had been trying, unsuccesfully, to get munin running for a college class project. After making a post on the course forum, it was pointed out that apache needed to be installed to access the graphs etc.

    This may seem like a logical thing to already have running, but ubuntu v6.10 doesn’t install it by default, and if you’re running a stand-alone PC, it’s not likely you are going to install web server software.

    Your article would have been much more helpfull if you had made mention of the fact that apache should be installed.

    Us humans need to know little things like that 🙁

  2. admin says:

    Thanks for your update and i have added to the main article to install apache web server

  3. glitch says:

    It also works under Lighttpd since munin isn’t using any Apache-specific modules.

  4. ashish says:

    Hello all,
    I am using munin for last couple of month.One problem i am facing. I am not able to check the Processes.Only blank graph shows in browser.and can you please tell what is the mean of “nan” and how can i remove this.

    regards
    ashish

  5. Ray says:

    nan stands for ‘Not A Number’.

    cannot offer you any more than that since i haven’t actually used this app.

  6. Imran says:

    After installation I see only blank grahps, they are not going to update and show status at all.

  7. Jon Alvarado says:

    For the blank graphs problem (which I was also having). You need to uncomment this line and do the force update.

    #host_name localhost.localdomain

  8. Jean-Luc B. says:

    Hi,

    Please do NOT use the command
    It will chown the rrd files to root… and munin can’t write anymore to these files
    I think you should prefer this command: to force the first update

  9. Bill says:

    do this to properly force the update…

    sudo /bin/sh
    su – munin -s /bin/sh munin-update
    exit

Leave a Reply

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