Installing Munin on Ubuntu 16.04

Installing Munin on Ubuntu 16.04 is not the hard. Munin is a monitoring system that runs over the network for the local server and remote servers. It monitors all the basics out of the box. We can use it to monitor servers of all types to see what has happened and help find out why stuff broke or started to go slow.

Before we start Installing Munin on Ubuntu 16.04, you will need a server. This post will start with a minimal install of Ubuntu 16.04. Yours will no doubt have some extra functionality other than allowing ssh :-).

Installing the Munin Server

Munin will generate graphs that are viewed via a web application. So the first thing we need is an Apache web server. You can also use Nginx or Lighthttpd. Munin also has a zoom feature so will will install the packages for that as well.

sudo apt-get update
sudo apt-get install apache2 apache2-utils libcgi-fast-perl libapache2-mod-fcgid

We can now turn on the fcgid module within apache.

sudo a2enmod fcgid

At this point you may see a warning when restarting Apache, this can be ignored for now. You should fix it before going into production.

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

Installing Munin

We can now install the Munin software for its server side. You only need to do this on one machines. All other machines only need to be Munin nodes. That way you can use one web site to monitor all your servers. By installing the packages listed below all the other default packages will be pulled in as well.

sudo apt-get install munin munin-node munin-plugins-extra

Configure Munin Master

During the install most of the configuration has already been done for us. There are of course a few exceptions. It we didn’t have the exceptions we would not have a job.

Munin puts all its configuration files in /etc/munin, where else? We can start with editing the Munin configuration file /etc/munin/munin.conf

sudo nano /etc/munin/munin.conf

At the top of the file we can uncomment the following lines there is no need to point these anywhere else.

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

The second change we need to make in this file is to the name of the master server. It will appear on the web interface. The default localhost.localdomain is not particularly descriptive. Down towards the end of the file you will see

[localhost.localdomain]
    address 127.0.0.1
    use_node_name yes

Change the name to something more description. It does not have to be ah host.domain format. We could use MailServer, WebServer or mail.dragon.lab. It is just text for the web interface.

[MyServer.One]
    address 127.0.0.1
    use_node_name yes

Save the file and close the editor.

We can now move on to the Apache configuration file. The default file is configured to only allow access from the localhost. For this post we can remove that and allow access from anywhere. You will want to put some restrictions on who can access this information before going into production.

sudo nano /etc/munin/apache.conf

Throughout the file you will see lines simlar to:

        Order allow,deny
        Allow from localhost 127.0.0.0/8 ::1
        Allow from all
        Options None

Replace them with the following

        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

We can now restart the services for apache2 and monin-node.

sudo service apache2 restart
sudo service munin-node restart

We should now be able to see the Overview page from the Munin web master at http://servername/munin/.
That is all there is for one machine and a basic installation. See below, where we scan for new or additional plugins.

Configuring Munin Nodes

As we said at the beginning of this post we only need one Munin master and we can add nodes to that interface. Here we will configure a Munin node on a remote server.

Installing a Node

We can install the node software with the following:

sudo apt-get install munin-node

The configuration file is again in /etc/munin but this time we will edit munin-node.conf

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

Towards the middle of the file around line 40 we can see a section talking about a list of addresses that are allowed to connect. we need to add a new Allow line with the IP address of our Munin Master.

allow ^10\.1\.200\.3$

Save the change and exit the editor.

restart the Munin-node service to take those changes into use

sudo service munin-node restart

Now back on the Munin Master, our first Munin machine. We need to tell it to look for monitoring on our node. Edit the Munin configuration file.

sudo nano /etc/munin/munin.conf

Add a new block for the new node with a description name in the same format as you used for the Munin master. The IP address is the address for the node server.

[MyServer.Two]
    address 10.1.200.5
    use_node_name yes

Restart the apache server on the Munin Master.

sudo service apache2 restart

Yuo may have to wait 5-10 minutes for Munin to find your new node. Once it does the new node will appear in to the overview page and graphs will start to be drawn.

Checking for New Plugins

We can check to see if there are new plugins that can be used to monitor additional services on our server, by using the command munin-node-configure.

sudo munin-node-configure --suggest

It will output a list of plugins that are available and whether or not they can be used on your server. Some of the plugins may require extra modules and packages to be installed before they can be used. Take a look and see what you like the look of.

To enable a plugin by hand you need to create a symbolic link in /etc/munin/plugins that points back to the plugin file from, /usr/share/munin/plugins/. For example to turn on the MySQl plugins we could do the following:

cd /etc/munin/plugins
sudo ln -s /usr/share/munin/plugins/mysql_
sudo ln -s /usr/share/munin/plugins/mysql_bytes
sudo ln -s /usr/share/munin/plugins/mysql_queries
sudo ln -s /usr/share/munin/plugins/mysql_slowqueries
sudo ln -s /usr/share/munin/plugins/mysql_threads

After adding new plugins restart the Munin node server to take them into use.

service munin-node restart

After a minute or so the new services will appear in the graphs on the Munin Master.

If you add the –shell option to the munin-node-configure it will generate the symbolic links for all the plugins that should work. You can then choose which plugins to activate.

sudo munin-node-configure --shell

Remember to restart the munin-node if any are added.

MySQL plugins

To run the Mysql plugins for Munin you will need to install the Cache::Cache module for Perl and make sure the mysql* symbolic links are in place in /etc/munin/plugins.

sudo apt-get install libcache-cache-perl libipc-sharelite-perl

If you are using innodb tables, you may need to create the file /etc/munin/plugin-conf.d/mysql_innodb file. Put the following in the file. It will stop the nonsense warning about the free size of InnoDB tables.

[mysql_innodb]
env.warning 0
env.critical 0

After adding the new Perl module and checking the links restart the Munin node server to take them into use. You may have to wait 5-10 minutes before they new graphs appear in Munin.

service munin-node restart

Leave a Reply

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