Server monitoring with Munin on Debian 9 (Stretch) and Debian 10 (Buster)

botond published 2020. 02. 17., h - 14:42 time

Content

  1. page: Installation and overview of Munin server monitor system
  2. page: Install, uninstall, and set password protection for Munin plugins

 

The 1. page content

 

Introductory

By making the web and other services running on our server available to the public, there may be a need for a comprehensive monitoring system that allows us to track information about the utilization of various resources on our server from one place. Many of these softwares are available today, and in this tutorial we will look at the installation and commissioning of a server monitor package called Munin on Debian 9 (Stretch) and Debian 10 (Buster).

 

 

Munin is a featherweight program written in Perl that runs in the background (in cron) to gather information from every corner of the system from which to build its database. The other part of the program creates graphs from the collected data, which it then makes available through the web server. The greatness of the system lies in its simplicity: nothing is chilly, it just serves the various statistics in the form of png images pasted into simple html pages. Furthermore, thanks to its modular structure, many plugins can be obtained, for example GitHub Munin from their contributors page. Its interface is very simple, so we can easily monitor all points of our server. The system, which can be separated from the central part, is a so-called it is made up of nodes that need to be installed and run on the server you want to monitor, which then sends the data to the central part. As a result, Munin can monitor multiple servers from one location at a time, but in this guide we will only test the usage installed on one machine.

 

Update (2023-01-25):
I also tested the description on a Debian 11 (Bullseye) system, everything works. In the case of installation on Debian 11, where the description splits, proceed with the Debian 10 parts.

 

Prerequisites

Munin Server Monitor can be installed on virtually any Debian environment, but Debian in your luggage Due to the differences in functionality between the available program versions, we will only cover the versions available on Debian 9 and Debian 10 here. In the previous Debian 8 (Jessie) repository the difference package is so old that it had to be brought to life in a different way. So you can use this description to install Munin server statistics on any of the following server configurations:

Minimum Servers:

LAMP Servers:

Perfect Servers:

Of course, the more complex our server, the more services Munin can monitor, so the more justified its use. Of the above, I tested the Munin installation on the two featured servers. Accordingly, newer versions of servers will already include this add-on.

 

Preparations

For Debian 9 (Stretch), set up the backports repository

Debian 9 (Stretch) backports repository available at munin package 2.0.49version, which is the same as the Debian 10 (Buster) repository versions. Therefore, if you are installing on Debian 9, you need to configure the backports repository, because 2.0.33version.

However, if you install Debian 9 on a perfect server, where the backports repository has already been configured, Let's Encrypt during installation, you can skip this section, check this setting anyway.

To configure the repository, log in as root and open /etc/apt/sources.list in the dwarf-with:

nano /etc/apt/sources.list

And add the following lines:

deb http://ftp.debian.org/debian stretch-backports main contrib non-free
deb-src http://ftp.debian.org/debian stretch-backports main contrib non-free

Updating libraries

After changing your luggage list, it is strongly recommended that you update your luggage database and packages in the usual way, and before installing smaller or larger ones:

apt-get update
apt-get upgrade

Then, if we look at the package it is apt-cache command, you can see the versions:

apt-cache policy munin

Outputs to Debian 9:

Checking the Munin package on Debian 9 (Stretch)

And Debian 10:

Checking the Munin package on Debian 10 (Buster)

 

 

Installing Munin

Package dependencies and installing the base package

Of the server configurations listed earlier, these servers may already be installed on the perfect servers, but to make sure they work everywhere, run the following command:

apt-get -y install \
    apache2 \
    libapache2-mod-fcgid \
    libcgi-fast-perl \
    perl perl-base

Enable the fcgid package (this is already enabled on perfect servers):

a2enmod fcgid

Then install the Munin system packages.

Debian 9

For Debian 9, install separately from the backports repository:

apt install -t stretch-backports \
    munin \
    munin-common \
    munin-node \
    munin-plugins-core \
    munin-plugins-extra
If you have added the Debian backports repository to our list of libraries, by default it is APT package manager does not prefer this when installing / updating packages, but rather, traditional repositories. Thus, during normal installations and package upgrades, we still get stable versions of packages. If you want to install something from the backports container separately, you can do so as above to get newer versions of the packages listed. Of course, further updates of the packages installed in this way will be applied from here.

Debian 10/11

And install it on Debian 10 as usual:

apt-get -y install \
    munin \
    munin-common \
    munin-node \
    munin-plugins-core \
    munin-plugins-extra

Configure configuration

Open your configuration file for editing:

nano /etc/munin/munin.conf

And make the following settings:

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

[...]

#tmpldir /etc/munin/templates

[...]

# a simple host tree
[szerverünk_FQDN_neve]
address 127.0.0.1
use_node_name yes

[...]

  • Take out the comments highlighted in red
  • Slightly below Replace the green highlighted part (in the original file: localhost.localdomain) on our server FQDN name (full name). If we don't know exactly, then this hostname It can also be read with the -f command. Here, make sure that the name of the server is between square brackets.

Configuring Apache

Open it for editing in Munin Apache configuration file:

nano /etc/munin/apache24.conf

And here are some changes:

[...]

<Directory /var/cache/munin/www>
	#Require local
	Require all granted
	Options FollowSymLinks SymLinksIfOwnerMatch
	Options None
</Directory>

<Directory /usr/lib/munin/cgi>
	#Require local
	Require all granted
	Options FollowSymLinks SymLinksIfOwnerMatch
	<IfModule mod_fcgid.c>
		SetHandler fcgid-script
	</IfModule>
	<IfModule !mod_fcgid.c>
		SetHandler cgi-script
    </IfModule>
</Directory>

[...]

Here, too, in both blocks, comment on the Require location lines, and insert the extra 2x2 lines according to the green pattern.

Then restart Apache and munin node:

systemctl restart apache2
systemctl restart munin-node

Control of Munin

Check our Munin system in the browser server IP addresses or your hostname / munin subdirectory:

The system is updated every 5 minutes, so we may have to wait for the next update cycle when the web interface becomes available.
http://debian9.linuxportal.vm/munin/

Munin - Home page

http://debian10.linuxportal.vm/munin/

Munin - Home on Debian 10

If web pages are running on the server, the interface can also be accessed from the / munin subdirectories under their web addresses, provided they are configured in the hosts file of the host computer running the local or virtual machine. Sharp server environment (fixed IP address) and registered domain names of course it works without it. 

If we have done everything right, your start page will come in. In the left menu you can look at the graphs. But that's about the end of the description.

So Munin's core system comes to life, which already contains some plugins, but we can still install some as we like.

 

 

Web interface overview

This section was originally dedicated to the third page, but since the second page is longer than planned, it will provide a more optimal place to review web graphs. So the pictures in this section were taken after installing and configuring the plugins, so there are many more menus and graphs available. Of course, we do not cover every graph, only the most important ones. In addition, there are parts that do not work on the virtual machine (eg temperature sensors), which I replace with my server as a sample.

The interface itself, as I mentioned at the beginning, is very simple, low-cost, and in return we get an easy-to-read, almost comprehensive server analysis. Let's see Munin in action!

So when you re-enter the homepage, there are more categories of menus:

Munin home page after installing extensions

Going to the apache menu we find some graphs:

Munin - Apache menu

Here you can see one-day graphs of the different states of Apache. For example, how many queries the server receives on average per second, how many Apache workflows are currently running, etc ...

Clicking on any graph image will bring you to a more detailed page showing the daily, weekly, monthly and yearly graphs for that graph:

Munin - Apache menu - detailed display

The graphs appear in the same way in other menus. As I mentioned, the interface is very simple, but with informative graphs you can get a quick overview of the status of our server.

The graph outages occurred during the virtual machine downtime as I have been making this description for several days and the virtual machine is not running continuously.

In this menu you can get detailed information about the hard drives in your machine:

Munin - Disk menu

There are a lot of graphs here, scrolling down a bit is worth mentioning also the data transfer and utilization graphs:

Munin - Disk Menu 2.

This virtual machine is, of course, idle, but with a richer server running multiple web pages, we can get usable data about how our drives are performing.

In the two mysql menus you can get a plethora of graphs for everything with your database server:

Munin - Mysql Menu

Scrolling down a bit further, this graph just shows the rate at which SQL operations are running on the server. For example, it can be used to assess how web pages you run use databases (read / write) to optimally select, for example, the ASPs and their deployment scheme (eg raid settings) for the next server build.

 

 

There are many things you can do in the network section too:

Munin - Network menu

For example, the amount of data passing through our firewall or the speed of HTTP page downloads. A little further down the Fail2Ban You can also find out the number of IP addresses blocked by. Interestingly, here's my monthly Fail2Ban image on my server:

Munin - Network - Fail2Ban

Here, for example, the point is that since I banned a lot of robots, since then, the amount of prohibited IP addresses has fluctuated periodically, so they periodically try to come back. (But in return, there is no unnecessary CPU load ...)

Here we can track the temperatures of different hardware and things related to it:

Munin - Sensors - fan speeds

Munin - Sensors - HDD temperatures

Since they don't work in the virtual machine, I borrowed them from my server for illustration.

And finally, we also look at the system menu, which still has many graphs, some of which are:

Munin - System - CPU usage

Munin - System - Average load value

Munin - System - Memory usage

Of course, there are plenty of graphs in the system too, all of which would be superfluous to list here.

 

 

A next page we continue with the installation, management and use of the Munin plugins.

 

 

Navigation

This description consists of several pages: