Difference between revisions of "Munin"

From ArchWiki
Jump to: navigation, search
(Changed the path of the munin.conf)
(Added a section on using munin-node-configure, explained wildcard plugins in detail, added a link to Munin's plugin howto and fixed a few inconsistencies)
Line 15: Line 15:
 
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-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].
  
=== Installing Munin ===
+
=== munin and munin-node ===
  
 
There is currently a munin (munin-master) and a munin-node package in extra.
 
There is currently a munin (munin-master) and a munin-node package in extra.
Line 21: Line 21:
 
  # pacman -S munin munin-node
 
  # pacman -S munin munin-node
  
=== Installing an optional web server ===
+
=== 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 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]]
 
*[[LAMP|Apache]]
Line 32: Line 32:
  
 
== Configuration ==
 
== Configuration ==
 +
 +
=== Daemon ===
  
 
Add the daemon to /etc/rc.conf:
 
Add the daemon to /etc/rc.conf:
 +
 
  DAEMONS=(syslog-ng network netfs crond httpd '''munin-node''')
 
  DAEMONS=(syslog-ng network netfs crond httpd '''munin-node''')
 +
 +
=== 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
 +
 +
=== 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.
Line 44: Line 59:
  
 
Uncomment the htmldir entry in /etc/munin/munin.conf and change it to the directory created in the previous step:
 
Uncomment the htmldir entry in /etc/munin/munin.conf and change it to the directory created in the previous step:
 +
 
  htmldir /srv/http/munin
 
  htmldir /srv/http/munin
 +
 +
=== 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
  
You can run also run monin-cron manually for testing purposes.
+
You can run also run monin-cron manually for testing purposes:
  
 
  # su - munin --shell=/bin/bash
 
  # su - munin --shell=/bin/bash
 
  $ munin-cron
 
  $ munin-cron
  
== Testing the Installation ==
+
== Testing ==
  
Make sure munin-node is running.
+
Munin should be able to run now. To make sure everything works, start munin-node:
  
 
  #/etc/rc.d/munin-node start
 
  #/etc/rc.d/munin-node start
  
Run munin-cron manually to generate the HTML and graph images.
+
Then run munin-cron manually to generate the HTML and graph images:
  
 
  # su - munin --shell=/bin/bash
 
  # su - munin --shell=/bin/bash
 
  $ munin-cron
 
  $ munin-cron
  
Then test the interface by pointing your browser to the output directory or http://localhost/munin.
+
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.}}
 
{{Note|It might take a while for the graphs to have data, so be patient. Wait for about 30 minutes to an hour.}}
Line 71: Line 90:
 
== Plugins ==
 
== Plugins ==
  
There are many Munin plugins (and they're easy to write). You can start looking for plugins on the [http://muninexchange.projects.linpro.no/ MuninExchange].  
+
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 can't find a plugin that does what you want it's easy to write your own. Have a look at [http://munin-monitoring.org/wiki/HowToWritePlugins HowToWritePlugins] at the Munin documentation wiki to learn how.
  
Basically all plugins are installed in the following manner (although there are exceptions, review each plugin!):
+
=== 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
 
Download a plugin, then copy or move it to /usr/lib/munin/plugins
  
  cp <plugin> /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.}}
  
Link the plugin to /etc/munin/plugins
+
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:
  
  ln -s /usr/lib/munin/plugins/<plugin> /etc/munin/plugins/<plugin>
+
# munin-run <plugin>
  
And then test your plugin. You do not need to use the full path to the plugin, munin-run should be able to figure it out.
+
And restart munin-node:
  
  munin-run <plugin>
+
# /etc/rc.d/munin-node restart
  
Now restart munin-node
+
Finally, refresh the web page.
  
  /etc/rc.d/munin-node restart
+
=== Removing ===
  
Then refresh the web page; there should be no need to restart munin-master.
+
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 /etc/munin/plugins/ - there is no need to actually remove the plugin from /usr. Many scripts also follow the following naming convention <plugin>_<device>. This allows multiple links to a single plugin.
+
# rm /etc/munin/plugins/<plugin>

Revision as of 20:44, 25 March 2010

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.

Configuration

Daemon

Add the daemon to /etc/rc.conf:

DAEMONS=(syslog-ng network netfs crond httpd munin-node)

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

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

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

You can run also run monin-cron manually for testing purposes:

# su - munin --shell=/bin/bash
$ munin-cron

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 can't find a plugin that does what you want it's 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>