Difference between revisions of "Munin"

From ArchWiki
Jump to: navigation, search
m (Dependencies)
(Daemon: all the time, need to start befor for check if it's fine)
(39 intermediate revisions by 16 users not shown)
Line 1: Line 1:
[[Category:Office (English)]]
+
[[Category:Status monitoring and notification]]
"'''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.
+
[[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.''
  
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.
+
''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). " [http://munin.projects.linpro.no/ Munin]
+
''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. See a running [http://munin.ping.uio.no/ munin example]
+
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.
  
 
== Installation ==
 
== Installation ==
  
Munin relies on a client-server model. The client is munin-node, and the server is munin (refered to "munin-master" in the documentation). You ''must'' have munin-node and munin-master installed for this installation to work.  
+
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.projects.linpro.no/wiki/Documentation munin documentation wiki].
+
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].
  
The following guide sets up a munin under a directory beneath the html root.
+
=== munin and munin-node ===
  
===Dependencies===
+
There is currently a munin (munin-master) and a munin-node package in extra.
  
Munin requires the following packages:
+
  # pacman -S munin munin-node
  # pacman -S apache php php-apache
+
  
Add an entry to your rc.conf:
+
=== Optional web server ===
  DAEMONS=(syslog-ng network netfs crond '''httpd''')
+
  
Edit /etc/hosts.allow by adding the following line:
+
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:
  httpd:   ALL
+
  
'''Optional sanity check'''
+
*[[LAMP|Apache]]
 +
*[[Lighttpd]]
 +
*[[NginX]]
  
Start the webserver:
+
Or one of the other servers found in the [[:Category:Web Server|web server]] category.
  # /etc/rc.d/httpd start
+
  
Create a test document:
+
=== IPv6 ===
  # echo "Testing httpd" > /srv/http/index.html
+
  
Open a web browser and access http://127.0.0.1/, you should see the test document.
+
For IPv6 support on munin-node (using ''host :::1'' in /etc/munin/munin-node.conf) you need to install the following packages:
  
If it did not work try the following and check again:
+
*perl-socket6
# chown -R http:http /var/run/httpd/
+
*perl-io-socket-inet6
  
Finally, stop the webserver:
 
# /etc/rc.d/httpd stop
 
  
==== Apache Notes ====
+
== Configuration ==
  
The html root is located under /srv/http. This directory may not be created by default, so create it if not present:
+
=== Daemon ===
# mkdir -p /srv/http
+
  
Apache also creates (or uses) the user account and group of http:http. Make sure apache has permissions on these directories:
+
Start the daemon with
# chown http:http /srv/http
+
  
All of these settings can be changed in the /etc/httpd/conf/httpd.conf.
+
systemctl start munin-node
  
=== Installing Munin ===
+
Enable the daemon with
  
Currently there's a munin package in the [[AUR]], and a munin-node package in extra. Installing with [[yaourt]] is a great choice:
+
systemctl enable munin-node
  
$ yaourt -S munin munin-node
+
See [[Daemons]] for more information.
  
Now check /srv/http. There should be a munin directory.
+
=== Plugins ===
  
== Configuration ==
+
Run munin-node-configure with the --suggest option to have Munin suggest plugins that it thinks will work on your installation:
  
Add the daemon to /etc/rc.conf:
+
# munin-node-configure --suggest
  DAEMONS=(syslog-ng network netfs crond httpd '''munin-node''')
+
 
 +
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.
 +
 
 +
/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.
 +
 
 +
# 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 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.
 +
 
 +
=== Cron ===
 +
 
 +
Run the following to have munin collect data and update the generated HTML and graph images every 5 minutes:
  
Optional: Run the following to have munin update every 5 minutes:
 
 
  # crontab /etc/munin/munin-cron-entry -u munin
 
  # crontab /etc/munin/munin-cron-entry -u munin
  
== Testing the Installation ==
 
  
Start the services:
+
Configure your email server so that you can receive mails to "munin" user. If you use postfix, add this line in /etc/postfix/aliases
 +
 
 +
  munin:    root
 +
 
 +
And run the command
 +
 
 +
  newaliases
 +
 
 +
=== Permissions ===
 +
 
 +
Because many plugins read log files, it is useful to add "munin" user into "log" group:
 +
 
 +
# usermod -aG log munin
 +
 
 +
== Testing ==
 +
 
 +
Munin should be able to run now. To make sure everything works, start munin-node:
  
#/etc/rc.d/httpd start
 
 
  #/etc/rc.d/munin-node start
 
  #/etc/rc.d/munin-node start
  
Then test the interface by pointing your browser to:
+
Then run munin-cron manually to generate the HTML and graph images:
 +
 
 +
# su - munin --shell=/bin/bash
 +
$ munin-cron
 +
 
 +
And finally test the interface by pointing your browser to the output directory or [http://localhost/munin/ 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 [http://muninexchange.projects.linpro.no/ 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 [http://munin-monitoring.org/wiki/HowToWritePlugins 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/<plugin>
 +
 
 +
{{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:
 +
 
 +
# /etc/rc.d/munin-node restart
 +
 
 +
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 exmpale notice, that the plugin "apache_accesses" gives no output at all, when enabled. In order to run the plugin directly just run
  
  http://localhost/munin
+
# munin-run apache_accesses
  
{{Note|It might take a while for the graphs to have data, so be patient. Wait about 30 minutes to an hour.}}
+
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".

Revision as of 21:23, 6 April 2013

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-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 Munin documentation wiki.

munin and munin-node

There is currently a munin (munin-master) and a munin-node package in extra.

# pacman -S munin munin-node

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 host :::1 in /etc/munin/munin-node.conf) you need to install the following packages:

  • perl-socket6
  • perl-io-socket-inet6


Configuration

Daemon

Start the daemon with

systemctl start munin-node

Enable the daemon with

systemctl enable munin-node

See Daemons for more information.

Plugins

Run munin-node-configure with the --suggest option to have Munin suggest plugins that 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.

/srv/http/munin is used below, 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 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.

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 your email server so that you can receive mails to "munin" user. If you use postfix, add this line in /etc/postfix/aliases

 munin:    root

And run the command

 newaliases

Permissions

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

# usermod -aG log munin

Testing

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

#/etc/rc.d/munin-node start

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

# su - munin --shell=/bin/bash
$ 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/<plugin>
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:

# /etc/rc.d/munin-node restart

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 exmpale notice, that the plugin "apache_accesses" gives no output at all, when enabled. In order to run the plugin directly just run

# 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".