Tutorial

How To Install Munin on an Ubuntu VPS

Published on June 24, 2013
author

Etel Sverdlov and Justin Ellingwood

How To Install Munin on an Ubuntu VPS

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

What the Red Means

The lines that the user needs to enter or customize will be in red in this tutorial! The rest should mostly be copy-and-pastable.

About Munin

Munin is a helpful utility that provides a visual way to monitor a VPS. It is set up to be extremely plug and play. It can be installed very quickly through apt-get. We will be using Ubuntu 12.04 in this guide.

First, we will install and configure Munin on a monitoring server, and then we will add configuration options that will allow Munin to monitor a remote server.

Prerequisites

To start off, be sure that apache2 is installed on the VPS you will use for monitoring. You can ensure that this is the case by checking the apache version number:

apache2 –v

If it is not yet installed, you can go ahead and install it:

sudo apt-get install apache2

Step One—Install Munin

Munin itself can be installed through apt-get. Once has it has been downloaded, there are very few steps required to get the graphs displayed. The initial configuration will take place on the monitoring server.

Start by installing munin on the monitoring server. The munin package contains both the server components and the client components necessary to monitor the machine it is installed on. The server component can be used to monitor behavior across multiple servers, as we will be demonstrating later.

Install the server and client components with the following command:

sudo apt-get install munin

Once the package is installed, you only need to make a few changes to get your installation working.

Step Two—Configure Munin

Start off by opening the main munin configuration file:

sudo nano /etc/munin/munin.conf

There are a few lines that we have to pay particular attention to:

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

Dbdir stores all of the rrdfiles containing the actual monitoring information, htmldir stores the images and site files, logdir maintains the logs, and rundir holds the state files. All four lines should be uncommented.

Additionally the htmldir line should be changed to point your web directory. For this guide, we will point it to /var/www/munin.

The four lines should now look like this:

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

Additionlly, two other lines should be changed within the configuration file. "Tmpldir" should be uncommented and the server name on the line localhost.localdomain should be updated to display the hostname, domain name, or other identifier you'd like to use for your monitoring server. We will use "MuninMonitor" in this guide:

tmpldir /etc/munin/templates


[MuninMonitor]
    address 127.0.0.1
    use_node_name yes

Save and close this file for now.

Next, you will be editing Munin's apache configuration file to point apache in the right direction when you request the monitoring information. Open Munin's apache configuration file:

sudo nano /etc/munin/apache.conf

There are a few items that need to be addressed at the top of this file. We need to change both the alias declaration and the directory path to point to the "htmldir" attribute we set in the munin.conf file.

We also need to allow connections from outside of the local computer, since you are likely accessing this cloud server remotely.

Change the beginning of this file to reflect this information:

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

Next, you will need to create the directory path that you referenced in the munin.conf file and modify the ownership to allow munin to write to it:

sudo mkdir /var/www/munin
sudo chown munin:munin /var/www/munin

Once all of these changes are in place, you can restart apache and munin to make the changes effective.

sudo service munin-node restart
sudo service apache2 restart

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.

Step Three—Configure Remote Monitoring

Munin can easily monitor multiple servers at once. The remainder of the article will focus on configuring a client setup that sends its data to the Munin monitoring server that we have configured. This scenario can easily scale to accommodate a number of clients.

Remote Client Setup

Log into the client VPS that you want to monitor.

The remote client machine does not need all of the munin components or apache2 installed. It only requires the client tools. You can install these through apt-get with the following commands:

sudo apt-get update
sudo apt-get install munin-node

Next, you need to edit the munin-node.conf file to specify that your monitoring server is allowed to poll the client for information. Open the file for editing:

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

Search for the section that has the line "allow ^127\.0\.0\.1$". Modify the IP address to reflect your monitoring server's IP address.

The IP entry should begin with a carat character (^), have four sets of numbers separated by a backslash and dot (\.), and end with a dollar sign ($). Below is a sample entry that you will need to change for your own setup:

allow ^123\.456\.78\.100$

Save and close the file.

Restart the munin-node service:

sudo service munin-node restart

Monitoring Server Setup

You now need to edit the configuration files for the monitoring server again. Log into the monitoring server now.

First, edit the munin.conf file:

sudo nano /etc/munin/munin.conf

Find the host list that you modified with your monitoring server's name:

[MuninMonitor]
	address 127.0.0.1
	use_node_name yes

Copy that section and paste it below the current entry. We will modify the name and the IP address to reflect the client server's information that we are configuring:

[MuninClient]
	address 111.222.333.444
	use_node_name yes

Save and close the file.

Restart the apache server to reload the configuration:

sudo service apache2 restart

Once again, it will take a few minutes for the correct files to be generated and pulled from the remote client.

After a few moments, if you return to your "MonitoringServerIPAddress/munin" page, you should see an option to view your remote client machine.

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

Learn more about our products

About the authors
Default avatar
Etel Sverdlov and Justin Ellingwood

author

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!

How do I get the servers internal ip address? The control Panel lists only the public ip addresses.

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
September 1, 2013

@sridharpandu: We currently do not support internal networking however we have a beta and are hoping to release it soon for NYC2 droplets.

Excellent tutorial.

Some more points on configuring munin

  • I would recommend to create a symlink pointing /var/cache/munin/www to your actual htmldir since this config option is not applies for all munin related thing (eg. munin-check throws an error if you move your www dir)
  • Adding an alias is not always a good idea. If you use Virtualmin or many vhosts for apache, you probably don’t want to reach munin on all virtualhost.
  • You should password this directory

One more point: if you use Mod_Security you should whitelist 127.0.0.1 for apache: SecRule REMOTE_ADDR “^127.0.0.1$” phase:1,nolog,allow,ctl:ruleEngine=Off

Has anyone gotten the plugin diskstats working with Munin on the Digital Ocean VPS? The disk (/dev/disk/by-label/DOROOT or /dev/vda(?)) doesn’t seem to give any info/different tools can’t detect it properly. Could it be that the disk just doesn’t give any info at all? I tried adding “[diskstats]\nroot” to /etc/munin/plugin-conf.d/munin-node and it didn’t seem to help.

Seems that adding it to root worked after all, it was just very slow to start. Added the line “env.include_only vda,disk/by-label/DOROOT” aswell under “[diskstats]”, but seeing as it only shows vda on the graph it seems to only require one to define the user to be root.

I am using nginx as the backend server. Is Apache necessary for Munin? If not, can you explain how to setup Munin on an nginx server?

Hi, I have a droplet with nginx, I set up the bhost but I cant make it work. It is not showing any image

This is the instance: http://monitor.germanlena.com.ar/

Do you have any idea why is it happening?

This is my nginx config:

server { listen 80; root /usr/share/nginx/www/munin/; server_name monitor.germanlena.com.ar; index index.php index.htm index.html;

    location / {
            try_files $uri $uri/ /index.html;
    }


    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/www;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
            deny all;
    }

}

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
January 13, 2014

@german.lena: Images might not appear until Munin collects enough data. Try now, it works for me.

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!

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.