How To Install and configure Munin on an Ubuntu Server/Client

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.


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

    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  ::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:


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


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:

	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:

	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.

Protect The Munin Output Directory with Password

To protect the munin Output Directory with Password, open and edit /etc/munin/apache.conf with following configuration below:

sudo nano /etc/munin/apache.conf
Alias /munin /var/cache/munin/www
<Directory /var/cache/munin/www>
       Order allow,deny
#      Allow from localhost ::1
       Allow from all
       Options None
#      This file can be used as a .htaccess file, or a part of your apache
#      config file.
#      For the .htaccess file option to work the munin www directory
#      (/var/cache/munin/www) must have "AllowOverride all" or something
#      close to that set.
       AllowOverride None
       AuthUserFile /etc/munin/munin-htpasswd
       AuthName "Munin"
       AuthType Basic
       require valid-user
#      This next part requires mod_expires to be enabled.
#      Set the default expiration time for files to 5 minutes 10 seconds from
#      their creation (modification) time. There are probably new files by
#      that time.
      <IfModule mod_expires.c>
               ExpiresActive On
               ExpiresDefault M310

You must create the password for /etc/munin/munin-htpasswd. on this case we want to log in to munin with the username Munin, run the following command:

sudo htpasswd -c /etc/munin/munin-htpasswd Munin

Enter a password for Munin, restart your apache and munin-node, you’re done!

sudo service apache2 restart
sudo service munin-node restart

Access it from your favorite browser , on address bar type http://host/munin

Munin - Authentication

ubuntu server - munin


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: