Difference between revisions of "Munin"

From ArchWiki
Jump to: navigation, search
(refactor the deamon part with new systemctl commands)
(Daemon)
 
(55 intermediate revisions by 13 users not shown)
Line 1: Line 1:
 
[[Category:Status monitoring and notification]]
 
[[Category:Status monitoring and notification]]
 
[[ja:Munin]]
 
[[ja:Munin]]
'''''[http://munin-monitoring.org/ Munin]''' the monitoring tool surveys all your computers and remembers what it saw. It presents all the information in graphs through a web interface. Its emphasis is on plug and play capabilities. After completing a installation a high number of monitoring plugins will be playing with no more effort.''
+
From the [http://munin-monitoring.org/ project web page]:
  
''Using Munin you can easily monitor the performance of your computers, networks, SANs, applications, weather measurements and whatever comes to mind. It makes it easy to determine "what's different today" when a performance problem crops up. It makes it easy to see how you're doing capacity-wise on any resources.''
+
:''Munin'' the monitoring tool surveys all your computers and remembers what it saw. It presents all the information in graphs through a web interface. Its emphasis is on plug and play capabilities. After completing a installation a high number of monitoring plugins will be playing with no more effort.
  
''Munin uses the excellent [http://oss.oetiker.ch/rrdtool/ RRDTool] (written by Tobi Oetiker) and the framework is written in Perl, while plugins may be written in any language. Munin has a master/node architecture in which the master connects to all the nodes at regular intervals and asks them for data. It then stores the data in RRD files, and (if needed) updates the graphs. One of the main goals has been ease of creating new plugins (graphs).'' [http://munin-monitoring.org/]
+
:Using Munin you can easily monitor the performance of your computers, networks, SANs, applications, weather measurements and whatever comes to mind. It makes it easy to determine "what's different today" when a performance problem crops up. It makes it easy to see how you're doing capacity-wise on any resources.
 +
 
 +
:Munin uses the excellent [http://oss.oetiker.ch/rrdtool/ RRDTool] (written by Tobi Oetiker) and the framework is written in Perl, while plugins may be written in any language. Munin has a master/node architecture in which the master connects to all the nodes at regular intervals and asks them for data. It then stores the data in RRD files, and (if needed) updates the graphs. One of the main goals has been ease of creating new plugins (graphs). [http://munin-monitoring.org/]
  
 
Simply put, Munin allows you to make graphs about system statistics. You can check out University of Oslo's [http://munin.ping.uio.no/ Munin install] to see some examples of what it can do.
 
Simply put, Munin allows you to make graphs about system statistics. You can check out University of Oslo's [http://munin.ping.uio.no/ Munin install] to see some examples of what it can do.
Line 11: Line 13:
 
== Installation ==
 
== Installation ==
  
Munin relies on a client-server model. The client is munin-node, and the server is munin (referred as to "munin-master" in the documentation).
+
''Munin'' relies on a client-server model. The client is ''munin-node'', and the server is ''munin'' (referred as to "munin-master" in the documentation).
  
You will only need to install munin-master on a single machine, but munin-node will need to be installed on all machines you wish to monitor. This article will focus on a single-machine installation. Further documentation may be found on the [http://munin-monitoring.org/wiki/Documentation Munin documentation wiki].
+
You will only need to install ''munin'' on a single machine, but ''munin-node'' will need to be installed on all machines you wish to monitor. This article will focus on a single-machine installation. Further documentation may be found on the [http://munin-monitoring.org/wiki/Documentation Munin documentation wiki].
  
 
=== munin and munin-node ===
 
=== munin and munin-node ===
  
There is currently a munin (munin-master) and a munin-node package in extra.
+
[[Install]] the {{Pkg|munin}} (munin master) and {{Pkg|munin-node}} packages.
 
+
# pacman -S munin munin-node
+
  
 
=== Optional web server ===
 
=== Optional web server ===
Line 25: Line 25:
 
The following guide sets up Munin to generate static HTML and graph images and write them in a directory of your choosing. You can view these generated files locally with any web browser. If you want to view the generated files from a remote machine, then you want to install and configure one of the following web servers:
 
The following guide sets up Munin to generate static HTML and graph images and write them in a directory of your choosing. You can view these generated files locally with any web browser. If you want to view the generated files from a remote machine, then you want to install and configure one of the following web servers:
  
*[[LAMP|Apache]]
+
*[[Apache]]
 
*[[Lighttpd]]
 
*[[Lighttpd]]
*[[NginX]]
+
*[[Nginx]]
  
Or one of the other servers found in the [[:Category:Web Server|web server]] category.
+
Or one of the other servers found in the [[:Category:Web server|web server]] category.
  
 
=== IPv6 ===
 
=== IPv6 ===
  
For IPv6 support on munin-node (using ''host :::1'' in /etc/munin/munin-node.conf) you need to install the following packages:
+
For IPv6 support on ''munin-node'', using:
  
*perl-socket6
+
{{hc|/etc/munin/munin-node.conf|
*perl-io-socket-inet6
+
host :::1
 +
}}
  
 +
Install:
 +
 +
*{{Pkg|perl-socket6}}
 +
*{{Pkg|perl-io-socket-inet6}}
  
 
== Configuration ==
 
== Configuration ==
Line 43: Line 48:
 
=== Daemon ===
 
=== Daemon ===
  
Enable the daemon with
+
On the nodes, start and enable {{ic|munin-node}}.
  
  systemctl enable munin-node
+
  # systemctl enable --now munin-node
  
and start it with
+
On the master, use a systemd timer as described below.
  
systemctl start munin-node
 
 
See [[Daemons]] for more information.
 
 
=== Plugins ===
 
=== Plugins ===
  
Run munin-node-configure with the --suggest option to have Munin suggest plugins that it thinks will work on your installation:
+
Run {{ic|munin-node-configure}} with the {{ic|--suggest}} option to have Munin suggest plugins it thinks will work on your installation:
  
 
  # munin-node-configure --suggest
 
  # munin-node-configure --suggest
  
If there is a suggestion for a plugin you want to use, follow that suggestion and run the command again. When you are satisfied with the plugins suggested by munin-node-configure, run it with the --shell option to have the plugins configured:
+
If there is a suggestion for a plugin you want to use, follow that suggestion and run the command again. When you are satisfied with the plugins suggested by {{ic|munin-node-configure}}, run it with the {{ic|--shell}} option to have the plugins configured:
  
 
  # munin-node-configure --shell | sh
 
  # munin-node-configure --shell | sh
Line 64: Line 66:
 
=== Directories ===
 
=== Directories ===
  
Create a directory where the munin-master will write the generated HTML and graph images. The munin user must have write permission to this directory.
+
Create a directory where the ''munin-master'' will write the generated HTML and graph images. The munin user must have write permission to this directory.
  
/srv/http/munin is used below, so the generated output can be viewed at [http://localhost/munin/ http://localhost/munin/] provided that a web server is installed and running.
+
The following example uses {{ic|/srv/http/munin}}, so the generated output can be viewed at [http://localhost/munin/ http://localhost/munin/], provided that a web server is installed and running:
  
 
  # mkdir /srv/http/munin
 
  # mkdir /srv/http/munin
 
  # chown munin:munin /srv/http/munin
 
  # chown munin:munin /srv/http/munin
  
Uncomment the htmldir entry in /etc/munin/munin.conf and change it to the directory created in the previous step:
+
Uncomment the {{ic|htmldir}} entry in {{ic|/etc/munin/munin.conf}} and change it to the directory created in the previous step:
  
 
  htmldir /srv/http/munin
 
  htmldir /srv/http/munin
Line 77: Line 79:
 
=== Customization ===
 
=== Customization ===
  
Before running munin, you might want to setup the hostname of your system. In /etc/munin/munin.conf, the default hostname is "myhostname". This can be altered to any preferred host name. The hostname will be used to group and name the .rrd files in /var/lib/munin and further, used to group the html files and graphs in your selected munin-master directory.
+
Before running munin, you might want to setup the hostname of your system. In {{ic|/etc/munin/munin.conf}}, the default hostname is {{ic|myhostname}}. This can be altered to any preferred hostname. The hostname will be used to group and name the {{ic|.rrd}} files in {{ic|/var/lib/munin}} and further, used to group the html files and graphs in your selected ''munin-master'' directory.
  
 
=== Cron ===
 
=== Cron ===
  
Run the following to have munin collect data and update the generated HTML and graph images every 5 minutes:
+
Run the following to have Munin collect data and update the generated HTML and graph images every 5 minutes:
  
 
  # crontab /etc/munin/munin-cron-entry -u munin
 
  # crontab /etc/munin/munin-cron-entry -u munin
  
 +
Configure the email server to send mails to the ''munin'' user. If using postfix, add the following:
  
Configure your email server so that you can receive mails to "munin" user. If you use postfix, add this line in /etc/postfix/aliases
+
{{hc|/etc/postfix/aliases|
 +
munin:    root
 +
}}
  
  munin:   root
+
And run:
  
And run the command
+
# newaliases
  
  newaliases
+
=== systemd timer ===
 +
 
 +
Instead of a cron job a systemd timer can be used.
 +
 
 +
This needs a service unit configuration:
 +
 
 +
{{hc|/etc/systemd/system/munin-cron.service|2=
 +
[Unit]
 +
Description=Survey monitored computers
 +
After=network.target
 +
 
 +
[Service]
 +
User=munin
 +
ExecStart=/usr/bin/munin-cron
 +
}}
 +
 
 +
And a timer unit configuration:
 +
 
 +
{{hc|/etc/systemd/system/munin-cron.timer|2=
 +
[Unit]
 +
Description=Survey monitored computers every five minutes
 +
 
 +
[Timer]
 +
OnCalendar=*-*-* *:00/5:00
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 +
}}
 +
 
 +
Now, [[reload]] systemd configuration, [[start]] {{ic|munin-cron.timer}} and verify that everything is working:
 +
 
 +
$ journalctl --unit munin-cron.service
 +
$ less /var/log/munin/munin-update.log
 +
 
 +
Finally, [[enable]] {{ic|munin-cron.timer}}.
  
 
=== Permissions ===
 
=== Permissions ===
  
Because many plugins read log files, it is useful to add "munin" user into "log" group:
+
Because many plugins read log files, it is useful to [[Users and groups#Example adding a user|add]] {{ic|munin}} user into {{ic|log}} group:
  
  # usermod -aG log munin
+
  # usermod -a -G log munin
 +
 
 +
When {{ic|graph_strategy cgi}} is enabled in {{ic|/etc/munin/munin.conf}} ensure the directory {{ic|/var/lib/munin/cgi-tmp}} is owned by user and group {{ic|munin}} so that the {{ic|/usr/share/munin/cgi/munin-cgi-graph}} script is able to write the png files to this directory.
 +
 
 +
# chown munin: /var/lib/munin/cgi-tmp
  
 
== Testing ==
 
== Testing ==
  
Munin should be able to run now. To make sure everything works, start munin-node:
+
Munin should be able to run now. To make sure everything works, [[start]] {{ic|munin-node.service}}.
 +
 
 +
Change the user to {{ic|munin}} and open the shell with {{ic|-s}}/{{ic|--shell}} (this needs to be done from root shell, since {{ic|munin}} doesn't have a password):
  
  #/etc/rc.d/munin-node start
+
  # su -s /bin/bash munin
  
Then run munin-cron manually to generate the HTML and graph images:
+
Then run {{ic|munin-cron}} manually to generate the HTML and graph images:
  
  # su - munin --shell=/bin/bash
+
  munin> munin-cron
$ munin-cron
+
  
 
And finally test the interface by pointing your browser to the output directory or [http://localhost/munin/ http://localhost/munin/].
 
And finally test the interface by pointing your browser to the output directory or [http://localhost/munin/ http://localhost/munin/].
Line 123: Line 167:
 
Basically all plugins are added in the following manner (although there are exceptions, review each plugin!):
 
Basically all plugins are added in the following manner (although there are exceptions, review each plugin!):
  
Download a plugin, then copy or move it to /usr/lib/munin/plugins
+
Download a plugin, then copy or move it to {{ic|/usr/lib/munin/plugins}}:
  
  # cp <plugin> /usr/lib/munin/plugins/
+
  # cp ''plugin'' /usr/lib/munin/plugins/
  
Then link the plugin to /etc/munin/plugins:
+
Then link the plugin to {{ic|/etc/munin/plugins}}:
  
  # ln -s /usr/lib/munin/plugins/<plugin> /etc/munin/plugins/<plugin>
+
  # ln -s /usr/lib/munin/plugins/''plugin'' /etc/munin/plugins/
  
{{Note|Some plugins - known as wildcard plugins - can be used with multiple devices at once by linking them with different names. These plugins end with an underscore and are linked as <plugin>_<device> to be used on <device>. See the if_ plugin for an example.}}
+
{{Note|Some plugins - known as wildcard plugins - can be used with multiple devices at once by linking them with different names. These plugins end with an underscore and are linked as {{ic|<plugin>_<device>}} to be used on {{ic|<device>}}. See the {{ic|if_}} plugin for an example.}}
  
Now test your plugin. You do not need to use the full path to the plugin, munin-run should be able to figure it out:
+
Now test your plugin. You do not need to use the full path to the plugin, {{ic|munin-run}} should be able to figure it out:
  
  # munin-run <plugin>
+
  # munin-run ''plugin''
  
And restart munin-node:
+
And [[restart]] {{ic|munin-node.servce}}. Finally, refresh the web page.
 
+
# /etc/rc.d/munin-node restart
+
 
+
Finally, refresh the web page.
+
  
 
=== Removing ===
 
=== Removing ===
  
If you want to remove a plugin, simply delete the linked file in /etc/munin/plugins - there is no need to remove the plugin from /usr/lib/munin/plugins.
+
If you want to remove a plugin, simply delete the linked file in {{ic|/etc/munin/plugins}} - there is no need to remove the plugin from {{ic|/usr/lib/munin/plugins}}.
  
  # rm /etc/munin/plugins/<plugin>
+
  # rm /etc/munin/plugins/''plugin''
  
 
=== Debugging ===
 
=== Debugging ===
  
If you come across a plugin that is not working as expected (for example giving you no output at all) it might be interesting to run it directly. Fortunately there is a way to do this. Following the instructions until here, you will for exmpale notice, that the plugin "apache_accesses" gives no output at all, when enabled. In order to run the plugin directly just run
+
If you come across a plugin that is not working as expected (for example giving you no output at all) it might be interesting to run it directly. Fortunately there is a way to do this. Following the instructions until here, you will for example notice, that the plugin {{ic|apache_accesses}} gives no output at all, when enabled. In order to run the plugin directly:
  
 
  # munin-run apache_accesses
 
  # munin-run apache_accesses
  
The error "LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86." indicates that a perl function could not be found. To resolve the problem simply install the missing library in this case  "perl-libwww".
+
The following error:
 +
 
 +
LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86.
 +
 
 +
indicates that a [[perl]] function could not be found. To resolve the problem, [[install]] the missing library, in this case, {{Pkg|perl-libwww}}.
 +
 
 +
== Apache VirtualHost examples ==
 +
 
 +
Based on information found here:
 +
* http://guide.munin-monitoring.org/en/stable-2.0/example/webserver/apache-virtualhost.html
 +
* http://munin-monitoring.org/wiki/MuninConfigurationMasterCGI
 +
 
 +
In the next major release of Munin, things will be much simpler. Check it out:
 +
* http://guide.munin-monitoring.org/en/latest/example/webserver/apache-virtualhost.html
 +
 
 +
=== Basic static html ===
 +
 
 +
  <nowiki><VirtualHost *:80>
 +
    ServerName localhost
 +
    ServerAdmin  root@localhost
 +
 
 +
    DocumentRoot /srv/http/munin
 +
 
 +
    ErrorLog /var/log/httpd/munin-error.log
 +
    CustomLog /var/log/httpd/munin-access.log combined
 +
</VirtualHost></nowiki>
 +
 
 +
=== Static html with DynaZoom feature ===
 +
 
 +
Install {{pkg|perl-cgi-fast}}.
 +
 
 +
You must enable one of these:
 +
 
 +
* '''mod_cgid''' (or '''mod_cgi''' if using mpm_prefork_module) by uncommenting the line in httpd.conf.
 +
* Or install {{pkg|mod_fcgid}} and add "'''LoadModule mod_fcgid modules/mod_fcgid.so'''" in httpd.conf.
 +
 
 +
<nowiki><VirtualHost *:80>
 +
    ServerName localhost
 +
    ServerAdmin  root@localhost
 +
 
 +
    DocumentRoot /srv/http/munin
 +
 
 +
    ErrorLog /var/log/httpd/munin-error.log
 +
    CustomLog /var/log/httpd/munin-access.log combined
 +
 
 +
    # Rewrites
 +
    RewriteEngine On
 +
 
 +
    # Images
 +
    RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L]
 +
 
 +
    # Ensure we can run (fast)cgi scripts
 +
    <Directory "/usr/share/munin/cgi">
 +
        Require all granted
 +
        Options +ExecCGI
 +
        <IfModule mod_fcgid.c>
 +
            SetHandler fcgid-script
 +
        </IfModule>
 +
        <IfModule !mod_fcgid.c>
 +
            SetHandler cgi-script
 +
        </IfModule>
 +
    </Directory>
 +
</VirtualHost></nowiki>
 +
 
 +
=== Full dynamic ===
 +
 
 +
Use this VirtualHost if you want to set '''html_strategy''' and '''graph_strategy''' to "'''cgi'''". Page loads will take longer because all the HTML and PNG files will be dynamically generated, but the munin-cron run will take less time because it will not execute munin-html and munin-graph. This feature may become necessary for you if your master polls many nodes and the munin-cron risks taking more than 5 minutes.
 +
 
 +
Install {{pkg|perl-cgi-fast}}.
 +
 
 +
You must enable one of these:
 +
 
 +
* '''mod_cgid''' (or '''mod_cgi''' if using mpm_prefork_module) by uncommenting the line in httpd.conf.
 +
* Or install {{pkg|mod_fcgid}} and add "'''LoadModule mod_fcgid modules/mod_fcgid.so'''" in httpd.conf.
 +
 
 +
<nowiki><VirtualHost *:80>
 +
    ServerName localhost
 +
    ServerAdmin  root@localhost
 +
 
 +
    DocumentRoot /srv/http/munin
 +
 
 +
    ErrorLog /var/log/httpd/munin-error.log
 +
    CustomLog /var/log/httpd/munin-access.log combined
 +
 
 +
 
 +
    # Rewrites
 +
    RewriteEngine On
 +
 
 +
    # Static content in /static
 +
    RewriteRule ^/favicon.ico /etc/munin/static/favicon.ico [L]
 +
    RewriteRule ^/static/(.*) /etc/munin/static/$1          [L]
 +
 
 +
    # HTML
 +
    RewriteCond %{REQUEST_URI} .html$ [or]
 +
    RewriteCond %{REQUEST_URI} =/
 +
    RewriteRule ^/(.*)          /usr/share/munin/cgi/munin-cgi-html/$1 [L]
 +
 
 +
    # Images
 +
    RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L]
 +
 
 +
    <Directory "/etc/munin/static">
 +
        Require all granted
 +
    </Directory>
 +
 
 +
    # Ensure we can run (fast)cgi scripts
 +
    <Directory "/usr/share/munin/cgi">
 +
        Require all granted
 +
        Options +ExecCGI
 +
        <IfModule mod_fcgid.c>
 +
            SetHandler fcgid-script
 +
        </IfModule>
 +
        <IfModule !mod_fcgid.c>
 +
            SetHandler cgi-script
 +
        </IfModule>
 +
    </Directory>
 +
</VirtualHost></nowiki>
 +
 
 +
==Tips and Tricks==
 +
 
 +
===MySQL===
 +
 
 +
The MySQL plugin has extra dependencies available in the AUR: {{Pkg|perl-dbi}}, {{AUR|perl-cache-cache}}, and {{AUR|perl-ipc-sharelite}}
 +
 
 +
Additionally it is recommended to access the database through a separate [[MySQL]] user. To make another user via the following MySQL commands:
 +
{{bc|<nowiki>MariaDB> CREATE USER 'muninuser'@'localhost' IDENTIFIED BY 'muninpassword';
 +
MariaDB> GRANT SUPER,PROCESS ON *.* TO 'muninuser'@'localhost';
 +
MariaDB> GRANT SELECT ON mysql.* TO 'muninuser'@'localhost';
 +
MariaDB> FLUSH PRIVILEGES;</nowiki> }}
 +
 
 +
To configure Munin to use this new user, create:
 +
 
 +
{{hc|/etc/munin/plugin-conf.d/mysql_|<nowiki>[mysql_*]
 +
    env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
 +
    env.mysqluser muninuser
 +
    env.mysqlpassword muninpassword</nowiki>}}
 +
 
 +
===S.M.A.R.T.===
 +
 
 +
To enable monitoring of S.M.A.R.T. data, install the {{Pkg|smartmontools}} package, and use:
 +
 
 +
{{hc|/etc/munin/plugin-conf.d/munin-node|[smart_*]
 +
    user root
 +
    group disk}}
 +
 
 +
Then create the appropriate symlink for each disk to be monitored. As an example for {{ic|sda}}: {{bc|# ln -s /usr/lib/munin/plugins/smart_ /etc/munin/plugins/smart_'''sda'''}}
 +
 
 +
===lm_sensors===
 +
 
 +
Install {{Pkg|lm_sensors}} and configure according to [[lm_sensors#Setup]]. Assuming all goes correctly, create some symlinks:
 +
{{bc|# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan
 +
# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp
 +
# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt}}

Latest revision as of 05:15, 28 April 2016

From the project web page:

Munin the monitoring tool surveys all your computers and remembers what it saw. It presents all the information in graphs through a web interface. Its emphasis is on plug and play capabilities. After completing a installation a high number of monitoring plugins will be playing with no more effort.
Using Munin you can easily monitor the performance of your computers, networks, SANs, applications, weather measurements and whatever comes to mind. It makes it easy to determine "what's different today" when a performance problem crops up. It makes it easy to see how you're doing capacity-wise on any resources.
Munin uses the excellent RRDTool (written by Tobi Oetiker) and the framework is written in Perl, while plugins may be written in any language. Munin has a master/node architecture in which the master connects to all the nodes at regular intervals and asks them for data. It then stores the data in RRD files, and (if needed) updates the graphs. One of the main goals has been ease of creating new plugins (graphs). [1]

Simply put, Munin allows you to make graphs about system statistics. You can check out University of Oslo's Munin install to see some examples of what it can do.

Installation

Munin relies on a client-server model. The client is munin-node, and the server is munin (referred as to "munin-master" in the documentation).

You will only need to install munin on a single machine, but munin-node will need to be installed on all machines you wish to monitor. This article will focus on a single-machine installation. Further documentation may be found on the Munin documentation wiki.

munin and munin-node

Install the munin (munin master) and munin-node packages.

Optional web server

The following guide sets up Munin to generate static HTML and graph images and write them in a directory of your choosing. You can view these generated files locally with any web browser. If you want to view the generated files from a remote machine, then you want to install and configure one of the following web servers:

Or one of the other servers found in the web server category.

IPv6

For IPv6 support on munin-node, using:

/etc/munin/munin-node.conf
host :::1

Install:

Configuration

Daemon

On the nodes, start and enable munin-node.

# systemctl enable --now munin-node

On the master, use a systemd timer as described below.

Plugins

Run munin-node-configure with the --suggest option to have Munin suggest plugins it thinks will work on your installation:

# munin-node-configure --suggest

If there is a suggestion for a plugin you want to use, follow that suggestion and run the command again. When you are satisfied with the plugins suggested by munin-node-configure, run it with the --shell option to have the plugins configured:

# munin-node-configure --shell | sh

Directories

Create a directory where the munin-master will write the generated HTML and graph images. The munin user must have write permission to this directory.

The following example uses /srv/http/munin, so the generated output can be viewed at http://localhost/munin/, provided that a web server is installed and running:

# mkdir /srv/http/munin
# chown munin:munin /srv/http/munin

Uncomment the htmldir entry in /etc/munin/munin.conf and change it to the directory created in the previous step:

htmldir /srv/http/munin

Customization

Before running munin, you might want to setup the hostname of your system. In /etc/munin/munin.conf, the default hostname is myhostname. This can be altered to any preferred hostname. The hostname will be used to group and name the .rrd files in /var/lib/munin and further, used to group the html files and graphs in your selected munin-master directory.

Cron

Run the following to have Munin collect data and update the generated HTML and graph images every 5 minutes:

# crontab /etc/munin/munin-cron-entry -u munin

Configure the email server to send mails to the munin user. If using postfix, add the following:

/etc/postfix/aliases
munin:    root

And run:

# newaliases

systemd timer

Instead of a cron job a systemd timer can be used.

This needs a service unit configuration:

/etc/systemd/system/munin-cron.service
[Unit]
Description=Survey monitored computers
After=network.target

[Service]
User=munin
ExecStart=/usr/bin/munin-cron

And a timer unit configuration:

/etc/systemd/system/munin-cron.timer
[Unit]
Description=Survey monitored computers every five minutes

[Timer]
OnCalendar=*-*-* *:00/5:00

[Install]
WantedBy=multi-user.target

Now, reload systemd configuration, start munin-cron.timer and verify that everything is working:

$ journalctl --unit munin-cron.service
$ less /var/log/munin/munin-update.log

Finally, enable munin-cron.timer.

Permissions

Because many plugins read log files, it is useful to add munin user into log group:

# usermod -a -G log munin

When graph_strategy cgi is enabled in /etc/munin/munin.conf ensure the directory /var/lib/munin/cgi-tmp is owned by user and group munin so that the /usr/share/munin/cgi/munin-cgi-graph script is able to write the png files to this directory.

# chown munin: /var/lib/munin/cgi-tmp

Testing

Munin should be able to run now. To make sure everything works, start munin-node.service.

Change the user to munin and open the shell with -s/--shell (this needs to be done from root shell, since munin doesn't have a password):

# su -s /bin/bash munin

Then run munin-cron manually to generate the HTML and graph images:

munin> munin-cron

And finally test the interface by pointing your browser to the output directory or http://localhost/munin/.

Note: It might take a while for the graphs to have data, so be patient. Wait for about 30 minutes to an hour.

Plugins

There are many Munin plugins out there just waiting to be installed. The MuninExchange is an excellent place to start looking, and if you cannot find a plugin that does what you want it is easy to write your own. Have a look at HowToWritePlugins at the Munin documentation wiki to learn how.

Adding

Basically all plugins are added in the following manner (although there are exceptions, review each plugin!):

Download a plugin, then copy or move it to /usr/lib/munin/plugins:

# cp plugin /usr/lib/munin/plugins/

Then link the plugin to /etc/munin/plugins:

# ln -s /usr/lib/munin/plugins/plugin /etc/munin/plugins/
Note: Some plugins - known as wildcard plugins - can be used with multiple devices at once by linking them with different names. These plugins end with an underscore and are linked as <plugin>_<device> to be used on <device>. See the if_ plugin for an example.

Now test your plugin. You do not need to use the full path to the plugin, munin-run should be able to figure it out:

# munin-run plugin

And restart munin-node.servce. Finally, refresh the web page.

Removing

If you want to remove a plugin, simply delete the linked file in /etc/munin/plugins - there is no need to remove the plugin from /usr/lib/munin/plugins.

# rm /etc/munin/plugins/plugin

Debugging

If you come across a plugin that is not working as expected (for example giving you no output at all) it might be interesting to run it directly. Fortunately there is a way to do this. Following the instructions until here, you will for example notice, that the plugin apache_accesses gives no output at all, when enabled. In order to run the plugin directly:

# munin-run apache_accesses

The following error:

LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86.

indicates that a perl function could not be found. To resolve the problem, install the missing library, in this case, perl-libwww.

Apache VirtualHost examples

Based on information found here:

In the next major release of Munin, things will be much simpler. Check it out:

Basic static html

<VirtualHost *:80>
    ServerName localhost
    ServerAdmin  root@localhost

    DocumentRoot /srv/http/munin

    ErrorLog /var/log/httpd/munin-error.log
    CustomLog /var/log/httpd/munin-access.log combined
</VirtualHost>

Static html with DynaZoom feature

Install perl-cgi-fast.

You must enable one of these:

  • mod_cgid (or mod_cgi if using mpm_prefork_module) by uncommenting the line in httpd.conf.
  • Or install mod_fcgid and add "LoadModule mod_fcgid modules/mod_fcgid.so" in httpd.conf.
<VirtualHost *:80>
    ServerName localhost
    ServerAdmin  root@localhost

    DocumentRoot /srv/http/munin

    ErrorLog /var/log/httpd/munin-error.log
    CustomLog /var/log/httpd/munin-access.log combined

    # Rewrites
    RewriteEngine On

    # Images
    RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L] 

    # Ensure we can run (fast)cgi scripts
    <Directory "/usr/share/munin/cgi">
        Require all granted
        Options +ExecCGI
        <IfModule mod_fcgid.c>
            SetHandler fcgid-script
        </IfModule>
        <IfModule !mod_fcgid.c>
            SetHandler cgi-script
        </IfModule>
    </Directory>
</VirtualHost>

Full dynamic

Use this VirtualHost if you want to set html_strategy and graph_strategy to "cgi". Page loads will take longer because all the HTML and PNG files will be dynamically generated, but the munin-cron run will take less time because it will not execute munin-html and munin-graph. This feature may become necessary for you if your master polls many nodes and the munin-cron risks taking more than 5 minutes.

Install perl-cgi-fast.

You must enable one of these:

  • mod_cgid (or mod_cgi if using mpm_prefork_module) by uncommenting the line in httpd.conf.
  • Or install mod_fcgid and add "LoadModule mod_fcgid modules/mod_fcgid.so" in httpd.conf.
<VirtualHost *:80>
    ServerName localhost
    ServerAdmin  root@localhost

    DocumentRoot /srv/http/munin

    ErrorLog /var/log/httpd/munin-error.log
    CustomLog /var/log/httpd/munin-access.log combined


    # Rewrites
    RewriteEngine On

    # Static content in /static
    RewriteRule ^/favicon.ico /etc/munin/static/favicon.ico [L] 
    RewriteRule ^/static/(.*) /etc/munin/static/$1          [L] 

    # HTML
    RewriteCond %{REQUEST_URI} .html$ [or]
    RewriteCond %{REQUEST_URI} =/
    RewriteRule ^/(.*)          /usr/share/munin/cgi/munin-cgi-html/$1 [L] 

    # Images
    RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L] 

    <Directory "/etc/munin/static">
        Require all granted
    </Directory>

    # Ensure we can run (fast)cgi scripts
    <Directory "/usr/share/munin/cgi">
        Require all granted
        Options +ExecCGI
        <IfModule mod_fcgid.c>
            SetHandler fcgid-script
        </IfModule>
        <IfModule !mod_fcgid.c>
            SetHandler cgi-script
        </IfModule>
    </Directory>
</VirtualHost>

Tips and Tricks

MySQL

The MySQL plugin has extra dependencies available in the AUR: perl-dbi, perl-cache-cacheAUR, and perl-ipc-shareliteAUR

Additionally it is recommended to access the database through a separate MySQL user. To make another user via the following MySQL commands:

MariaDB> CREATE USER 'muninuser'@'localhost' IDENTIFIED BY 'muninpassword';
MariaDB> GRANT SUPER,PROCESS ON *.* TO 'muninuser'@'localhost';
MariaDB> GRANT SELECT ON mysql.* TO 'muninuser'@'localhost';
MariaDB> FLUSH PRIVILEGES; 

To configure Munin to use this new user, create:

/etc/munin/plugin-conf.d/mysql_
[mysql_*]
     env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
     env.mysqluser muninuser
     env.mysqlpassword muninpassword

S.M.A.R.T.

To enable monitoring of S.M.A.R.T. data, install the smartmontools package, and use:

/etc/munin/plugin-conf.d/munin-node
[smart_*]
    user root
    group disk
Then create the appropriate symlink for each disk to be monitored. As an example for sda:
# ln -s /usr/lib/munin/plugins/smart_ /etc/munin/plugins/smart_sda

lm_sensors

Install lm_sensors and configure according to lm_sensors#Setup. Assuming all goes correctly, create some symlinks:

# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan 
# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp
# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt