Tutorial

How To Install the Munin Monitoring Tool on Ubuntu 14.04

Published on June 20, 2015
How To Install the Munin Monitoring Tool on Ubuntu 14.04

Introduction

Munin is a system, network, and infrastructure monitoring application that provides information in graphs through a web browser. It is designed around a client-server architecture and can be configured to monitor the machine it’s installed on (the Munin master) and any number of client machines, which in Munin parlance, are called Munin nodes.

In this article, we’ll install and configure Munin to monitor the server it’s installed on and one node. To install Munin on multiple nodes, just follow the instructions for creating a node on each system.

Prerequisites

  • Two Ubuntu 14.04 Droplets. One of the servers will be the Munin master. The other will be the Munin node.
  • For each Droplet, a non-root user with sudo privileges

All the commands in this tutorial should be run as a non-root user. If root access is required for the command, it will be preceded by sudo. Initial Server Setup with Ubuntu 14.04 explains how to add users and give them sudo access.

Step 1 — Installing Required Packages

We will start working on the Munin master first. Before installing Munin, a few dependencies need to be installed.

Though Munin can function with most popular Web servers like Nginx and Lighttpd, it is, by default, designed to work with the Apache Web server. So be sure that Apache is installed and configured on the Munin master. If it’s not already installed, do so using:

  1. sudo apt-get update
  2. sudo apt-get install -y apache2 apache2-utils

To ensure that the dynazoom functionality, which is responsible for zooming into the generated graphs, work properly on click, install the following:

  1. sudo apt-get install -y libcgi-fast-perl libapache2-mod-fcgid

After installing those two packages, the fcgid module should be enabled. To double-check, type:

  1. /usr/sbin/apachectl -M | grep -i cgi

The output should be:

fcgid_module (shared)

If the output is blank, then it’s not enabled. You may then enable it using:

  1. sudo a2enmod fcgid

When executing the apachectl command, you can ignore the following warning:

Could not reliably determine the server's fully qualified domain name ...

Apache will still work with Munin with this warning.

The rest of the configuration that will make graph zooming work properly will be covered in Step 3.

Step 2 — Installing Munin on the Munin Master

Installation packages for Munin are available in the official Ubuntu repository, so they can be installed using the distribution’s package manager. In this step, you’ll install the Munin master package. The version in the repository is the latest stable release.

To install it to monitor the server it’s installed on, type:

  1. sudo apt-get install -y munin

Step 3 — Configuring the Munin Master

Munin’s main configuration file munin.conf and other files required for it to function are in the /etc/munin directory and its sub-directories. In this step, we’ll modify the main configuration file for the Munin master and its Apache configuration apache.conf.

The main configuration file is made up of at least two sections — a global and at least one host section. Optionally, there can be a group section. Host and group sections start with their respective names in square brackets. This file contains variable definitions, directives that govern how Munin monitors servers and services, and which servers to monitor.

To begin, open the main configuration file:

  1. cd /etc/munin
  2. sudo nano munin.conf

Look for these lines and uncomment them — remove the # sign that precedes them. The dbdir stores all of the rrdfiles containing the actual monitoring information; htmldir stores the images and site files; logdir maintains the logs; rundir holds the state files; and tmpldir is the location for the HTML templates. Be sure to change the htmldir from /var/cache/munin/www to your web directory. In this example, we’ll be using /var/www/munin:

/etc/munin/munin.conf
dbdir     /var/lib/munin
htmldir   /var/www/munin
logdir    /var/log/munin
rundir    /var/run/munin

tmpldir	/etc/munin/templates

Since the htmldir does not exist, let’s create and chown it so that it’s owned by the munin system user:

  1. sudo mkdir /var/www/munin
  2. sudo chown munin:munin /var/www/munin

Finally, in munin.conf, look for the first host tree. It defines how to access and monitor the host machine. It should read:

/etc/munin/munin.conf
[localhost.localdomain]
    address 127.0.0.1
    use_node_name yes

Change the name of that tree to one that uniquely identifies the server. This the name that will be displayed in the Munin web interface. In this example, we’ll be using MuninMaster, but you could also use the server’s hostname:

/etc/munin/munin.conf
[MuninMaster]
    address 127.0.0.1
    use_node_name yes

That’s all for the configuration file, so save and close it.

Within the same /etc/munin directory, the next file we’ll be modifying is apache.conf, which is Munin’s Apache configuration file. It is sym-linked to /etc/apache2/conf-available/munin.conf, which, in turn, is sym-linked to /etc/apache2/conf-enabled/munin.conf. To start modifying it, open it with nano:

  1. sudo nano apache.conf

At the very top of the file, modify the first line so that it reflects the htmldir path you specified in munin.conf and created previously. Based on the directory path used in this article, it should read as follows, which makes it so you can access Munin’s web interface by appending munin to the server’s IP address or domain hosted on the server:

/etc/munin/apache.conf
Alias /munin /var/www/munin

Next, look for the Directory section, and change the directory to /var/www/munin. Also comment out (or delete) the first four lines and then add two new directives so that it reads:

/etc/munin/apache.conf
<Directory /var/www/munin>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1
        #Allow from all
        #Options None

        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

        ...

        ...

</Directory>

Look for the penultimate location section, comment out or delete the first two lines and add two new ones so that it reads:

/etc/munin/apache.conf
<Location /munin-cgi/munin-cgi-graph>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1

        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

        ...

        ...

</Location>

Do the same to the last location section:

/etc/munin/apache.conf
<Location /munin-cgi/munin-cgi-html>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1

        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

        ...

        ...

</Location>

Save and close the file. Then restart Apache and Munin.

sudo service apache2 restart
sudo service munin-node restart

You may now access Munin’s web interface by pointing your browser to server-ip-address/munin

Munin Web Interface

Step 4 — Adding a Node to Munin Master

In this step, we’ll show how to add a remote server (or node) to the Munin master so that you can monitor it within the same web interface. This involves modifying the Munin master’s configuration file to specify a host tree for the node. Then, you will need to install the Munin node package on the node and modify its configuration file so that it can be monitored by the Munin master.

Let’s start with the Munin node — the second Ubuntu Droplet you created.

Log into the Munin node, update the package database and install the Munin node package:

  1. sudo apt-get update
  2. sudo apt-get install -y munin-node

After the installation has completed successfully, the node’s configuration file should be in the /etc/munin directory. Open it with nano:

  1. sudo nano /etc/munin/munin-node.conf

Towards the middle of the file, look for an allow ^127.0.0.1$ line and modify it so that it reflects the IP address of the Munin master. Note that the IP address is in regex format, so assuming that the master server’s IP address is 123.46.78.100, the line should read as follows:

[label  /etc/munin/munin-node.conf}
allow ^123\.456\.78\.100$

Save and close the file. Then restart the Munin:

  1. sudo service munin-node restart

Back on the Munin master, open the main configuration file:

  1. sudo nano /etc/munin/munin.conf

All we need to do in this file is insert a host tree for the (remote) node. The easiest approach to that is to copy and modify the host tree of the master. Be sure to replace node-ip-address with the IP address of the node you are adding:

/etc/munin/munin.conf
[MuninNode]
	address node-ip-address
	use_node_name yes

Save and close the file. Then restart Apache:

  1. sudo service apache2 restart

Munin checks for new nodes every 5 minutes. Wait a few minutes, and then reload the Munin master’s web interface. You should see an entry for the node. If you don’t see it yet, try again in 5 minutes. Using this method, you may add as many nodes as you have to monitor.

Munin Node Added

Step 5 — Enabling Extra Plugins

Munin monitors a system using plugin scripts, and by default, about a dozen set of plugins are installed and active. A complete list of available plugins are in the /usr/share/munin/plugins directory. To see which plugins can be used on your system, Munin provides the following command:

  1. sudo munin-node-configure --suggest

The output should be of this sort:

Plugin                     | Used | Suggestions
------                     | ---- | -----------
cps_                       | no   | no
cpu                        | yes  | yes
cpuspeed                   | no   | no [missing /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state]
cupsys_pages               | no   | no [could not find logdir]
df                         | yes  | yes
df_inode                   | yes  | yes
fail2ban                   | no   | yes
ip_                        | no   | yes

A plugin with a yes in the Used column means just what it indicates, while one with a yes in the Suggestions column means it can be used. One with a no on both columns means it is not in use and cannot be used on the system. Finally, if a plugin has a no in the Used column and a yes in the Suggestions, then it is not being used but can be enabled and used on the system.

On the Munin master and node, you can also see a list of installed plugins in the /etc/munin/plugins directory.

A munin-plugins-extra package should have been installed when you installed Munin. If it was not, do so using.

  1. sudo apt-get install munin-plugins-extra

To enable an available plugin that’s not currently in use, create a symbolic link for it from the /usr/share/munin/plugins directory to the /etc/munin/plugin directory.

For example, to enable the Fail2ban plugin, first install Fail2ban:

  1. sudo apt-get install fail2ban

Then, create the symlink that enables the Munin plugin:

  1. sudo ln -s /usr/share/munin/plugins/fail2ban /etc/munin/plugins

Restart Munin:

  1. sudo service munin-node restart

Wait a few minutes, reload the web interface, and you should see graphs for Fail2ban under the title Hosts blacklisted by fail2ban under the network category for the Munin master.

Troubleshooting

If you are having trouble configuring the Munin master, the Munin node, or getting the master to see the node, check out the log files for error messages:

  • Munin master: /var/log/munin/munin-update.log
  • Munin node: /var/log/munin/munin-node.log

You can also check the project’s page for additional troubleshooting tips.

Conclusion

Munin can be configured to monitor the system on which it is installed. Adding remote servers to the monitored system is as simple as install the munin-node package on the remote server (or node) and then modifying the server’s and node’s configuration files to point to the other IP address.

Munin works by using plugins, but not all are enabled out of the box. Information about plugins are available on the project’s page.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors
Default avatar
finid

author


Default avatar
Tammy Fox

editor


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I do all the steps in the tutorial and get this error when going to myip/munin:

Forbidden

You don’t have permission to access /munin/ on this server.

Any hints? I’m using Ubuntu 14.04 and Apache/2.4.7 (Ubuntu).

The command to restart munin master is wrong. sudo service munin-node restart This is the correct

I like this post. I am installing to test it.

Thanks

The Zooming in chart does not work! The image is not showing! Also would be nice to add notes about how to protect the access. For last, you talk about: “The rest of the configuration that will make graph zooming work properly will be covered in Step 3.” But there’s no such explanation!

For someone who got stuck as I here check out: http://stackoverflow.com/a/35602370/886034

This article is great, but as others mentioned, I had some difficulty setting up the htmldir according to the steps above. Instead, I used the default htmldir and everything appears to be working well. Here is a repo that you can use to quickly spin up a VM with Munin running: https://github.com/redgeoff/munin-vagrant

You may experience network graphs either not working or being a bit “off” (if_eth0, if_eth1) It seems the cause of this is (on Ubuntu and Debian at least) the plugin is unable to determine the speed of the interface, as it would with a physical connection.

The value can be defined in the configuration by by adding env.speed XXX like so:

[if_*]
user root
env.speed 100

I am unsure of what would be the correct speed setting, and I think this setting is used to show the reliable throughput.

I’ve tried it on Debian 8, where it would produce a nice graph although i think the numbers might be a bit low, but on an Ubuntu 14.04 droplet, the graph was not produced at all until i have I gave the plugin a value like above.

I’ve found this: https://www.digitalocean.com/community/questions/upload-and-download-speed-of-a-droplet

Does anyone know what the appropriate speed value should be?

Hello I’m really thank full for your post this is the best one for install & config munin I need some help to config SNMP for windows or router. and if you can help please complete your beautiful post by make munin update rate at one minute that’s what I really need thank you :)

Can you please add the following from an earlier tutorial?:

It might take a few minutes to generate the necessary graphs and html files. After about five minutes, your files should be created and you will be able to access your data. You should be able to access your munin details at:

your_ip_address/munin

If you get an error message in your browser similar to the following, you need to wait longer for munin to create the files:

Forbidden, You don’t have permission to access /munin/ on this VPS.

Are you able to access Munin from outside of the local network? If so, how do you set it up? I read that ports 4949 and 4948 are taken up by Munin but I’ve opened those ports up on UFW and my router but still can’t access Munin externally.

Hi, how can i monitor nginx on a munin-node if my munin-master only has apache and not nginx?

Great article, I found that things worked better for me when I didn’t try changing the htmldir directory. It worked out of the box without changing that. /var/www/munin was just blank. :( I wrote a post based on what’s here to get this working with Django.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel