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 an all-encompassing monitoring system that can track information about the utilization of various resources on our server from a single location. Many of these softwares are available nowadays, and in this tutorial we will look at installing and setting up the server monitor program Munin on Debian 9 (Stretch) and Debian 10 (Buster).

Munin is a lightweight program written in Perl that runs in the background (cron) and collects information from all corners of the system from which it builds its database. The other part of the program is making graphs of the data collected and then making it available through the web server. The greatness of the system lies in its simplicity: there is nothing chilly-wild, just png images pasted into simple html pages in the form of statistics. In addition, due to its modular structure, many plugins can be obtained, such as GitHub Munin from their contributors page. Its interface is very simple, so you can easily control every point of your server. The system, which is inseparable from its central part, It consists of nodes that must be installed on the server you want to monitor and run on, which then sends the data to the central part. Thanks to this, Munin can monitor multiple servers from one place at a time, but in this guide we will only try the application installed on one machine.

Prerequisites

Munin Server Monitor can be installed on virtually any Debian environment, but due to the differences in functionality between the Debian repositories, we only deal with the versions available on Debian 9 and Debian 10. Previously stored in Debian 8 (Jessie) the difference the package is so old that it had to be brought to life in a different way. Thus, this description can be used to install Munin server statistics on any of the following server configurations:

Minimum Servers:

LAMP Servers:

Perfect Servers:

Of course, the more sophisticated our server is, the more services Munin can monitor, so the more justified it is to use. Of the above, I tested the installation of Munin on the two highlighted servers. Accordingly, newer versions of the 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, but in any case, check this setting.

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, looking at the package, 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 above, the perfect servers may already have these packages installed, 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 libraries. This way, we will continue to get stable versions of packages during normal installs and package updates. If you want to install something from the backports repository, you can do so by getting the latest versions of the packages listed. Of course, further updates to packages that are installed this way will be applied here.

Debian 10

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 -f command. Here, make sure the server name is enclosed in 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 local 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:

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 daily graphs of the various states of Apache. For example, how many hits are sent to the server 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 you can keep track of the temperatures of different hardware and things like that:

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: