Jul 282014
 
Article Server Administration

Munin is a full-featured open source server monitoring tool that implements a web frontend for the visualization of the evolution of the most relevant performance parameters: CPU, main memory and disk usage, number of processes, etc.

This post goes through the steps involved in the setup and basic configuration of this useful tool.

Introduction

A Linux box has a limited amount of CPU, memory, disk and network resources. Processes running on the system compete for the usage of these resources, and it is the responsibility of the system administrator to prevent one of them from becoming a bottleneck that hinders the normal running of the system.

To carry out this task, the sysadmin should:

  • Implement a procedure to collect periodically the values of each of the most relevant parameters: CPU usage, disk usage, memory usage, disk I/O operations, network I/O operations, etc.
  • Define thresholds for each of these parameters, and setup a procedure to trigger an alert if any of them is reached. For instance, disk usage above 80%, number of disk I/O operations per second above 100, etc.
  • Set up a system to store the historical series of values measured for each of those parameters in a given date range. The system should enable the visualization of these time series as graphs, to make it easy the analysis of the evolution of these parameters, allowing the sysadmin to predict and react to future lack of resources, before it happens.

Munin is an open source package for monitoring linux servers that can be used for this purpose. Munin includes:

  • An extensible set of plugins to collect the values of the parameters being monitored
  • A client munin-node process that runs on each of the systems being monitored. When munin-node receives requests from a munin server, it runs the plugins enabled for the node, and delivers the results to the servers.
  • A server munin that gathers the information from each of the nodes being monitores, and stores it in “RRD” (Round Robin Database). The munin servers also includes a web frontend for the visualization of the stored information as a set of graphs.

1. Munin installation

Installing Munin on a Debian or Ubuntu system is just a matter of installing the standard packages “munin” and “munin-node” with apt-get:

2. Initial configuration

2.1. web frontend configuration

The most convenient way to setup the web frontend is to add a “VirtualHost” to the Apache web server. For instance, creating a file /etc/apache2/sites-enabled/100-munin with this content:

In this file, replace the value of ServerName “munin.example.com” with the actual server name that will be used to access the frontend.

The log directory “/var/log/apache2/munin” also needs to be created.

Next, reboot the apache web server, and access the main page of the munin frontend with the urls “http://munin.example.com”.

2.2 munin server configuration

The munin server configuration file is “/etc/munin/munin.conf”.

The nodes to be monitored are specified in this file, together with several configuration options of the web frontend.

The sample configuration file in the installation package can be used as-is for a simple installation with a single local munin node.

2.3 Configuración del cliente munin-node configuration

The munin-node configuration file is “/etc/munin/munin-node.conf”

3. Configuring plugins

Plugins retrieve from the system the values of the parameters being monitored. There are many different plugins for different types of  hardware and software resources. Only plugins related to resources available on a given system should be enabled, and other plugins sould be disabled.

The easiest way to enable all plugins applicable to a given system is by means of the munin-node-configure tool:

Executing munin-node-configure without parameters outputs a list of the existing plugins, indicating whether they are enabled or not:

–families

Each plugin belongs to a family: auto, contrib, manual or snmpauto. The –families option can be used to specify the families affected by the  munin-node-configure command. For instance, to list all available plugins in the families contrib and auto:

–suggest

Option –suggest lists all available plugins, indicating which of them are applicable to the system, and adding a brief explanation for the reason why some of them are not applicable:

In this example, the apache monitoring plugins are listed as not applicable, because the perl module LWP::UserAgent is not installed on the system. After installing the LWP::UserAgent module from CPAN, running again the munin-node-configure command shows that there is no other reason that prevent those modules from being enabled:

–shell

With option –shell, munin-node-configure prints the command that need to be executed to activate eligible plugins (option –shell implies option –suggest). In most cases, a plugin is activated by just creating a symbolic link under the directory /etc/munin/plugins, pointing to the plugin script that is located under /usr/share/munin/plugins:

In the example above, munin-node-configure is generating the commands to activate plugins apc_nis and meminfo, and also activate mysql_isam_space_ for each of the MySQL databases found on the system.

4. Adding a node to a munin server

Nodes to be monitored by a munin server are configured in the server configuration file “/etc/munin/munin.conf”. In a default installation, there is only one entry for the local node:

The munin server can be told to monitor a second node by adding a section for the node, with the node name enclosed in square brackets. The minimal configuration requires also specifying the IP address that will be used to connect to the node. For instance:

On node2, the file “/etc/munin/munin-node.conf” must also be edited, to:

a. Define the node name. Below the line “#host_name localhost.localdomain”, add:

b. grant access from the IP address of the munin server:

c. Tell munin-node to listen in the IPv4 address (by default, it only listens in the IPv6 address, it it is available). Locate and comment out the line “host *”, and add below it the line that specifies the IPv4 address of the client:

Finally, restart the client:

References

Munin Wiki – Installation of Munin Node and Master

 Posted by at 8:59 am

 Leave a Reply

(required)

(required)