To keep an eye on what's happening with our production servers I recently discovered Munin. It was trivial to install but I'm having a lot of trouble working out how to add/remove graphs.
I found some documentation suggesting I can reorder them but very little discussion about how to manage plugin configuration. The bulk of the plugin documentation discusses how to create plugins; rather than use them.
The question is pretty basic: How do I use the vast library of plugins so I can see what's happening with, for example, nginx, mysql and memcache.
Enable and disable plugins on each node
Graphs are added and removed via symlinks in the
/etc/munin/plugins/
directory of the node.To remove a graph you must remove the symlink and restart the node:
To add a graph you must add a symlink in the plugins directory to an executable. eg:
When you restart munin-node it runs immediately and any issues with the plugins appears in
/var/log/munin/munin-node.log
. If all is going well you'll see a CONNECT logged every cycle; this records the fact that the master connected to collect the latest data.Configuring plugins on the node
Install prerequisite modules
But it may be that things don't go well. Errors when running the plugins are logged here as well and are critical clues to getting a plugin to work. Here we see a problem with the nginx_request plugin...
Plugins are executable programs - mostly written in Perl. There is a big collection installed at
/usr/share/munin/plugins/
(Ubuntu). Being mostly user-contributed they appear to vary wildly in quality but all of them need to query the system for the data it needs then arrange it into a format munin can use.Most of them rely on either a Perl library which you may or may not have installed already, or a diagnostic program for the service of interest. For example the plugin for varnish requires varnishstat. Similarly the plugin for memcached.
But back to the problem above... whereby, fortunately I've done a little bit of Perl in my time, and make an educated guess that the plugin requires a perl module LWP::Useragent. If you open the plugin that's throwing errors it may give you some clues to what it's requirements are. Some of them you can run from the commandline to see what happens/if they work.
To continue the example above this might squash the nginx_request error shown above:
Or it may not...
Enable data sources
By way of example, nginx, if you take a peek at the src of the plugin it will reveal that it collects it's data from
http://localhost/nginx-status
so you'll need to enable that. Or, as previously mentionedvarnishstat
is an example.Or it may be right to go as is.
Provide environment variables
Additionally you might need to feed the plugin some environment/configuration variables. This is done by editing
/etc/munin/plugin-conf.d/munin-node
and adding whatever it needs. eg:You can also do this by creating a new file with this kind of content as it will process any file in that directory; but I didn't try that.
To test the plugin such that it actually reads the environment variables there is a tool
munin-run
. Use it just by naming the file in the plugins dirWhat about these plugins with hanging underscore filenames?
Quite a lot of plugins in the
/usr/share/munin/plugins/
directory have plugins which don't work if you just symlink to them. They are the ones with an underscore as their last character. eg:memcached_
,diskstat_
,if_
. They leave the hanging underscore so they can be reused with varying parameters.To use them symlink from
/etc/munin/plugins/
but append a parameter which (a) may be a keyword egmemcached_bytes
or, (b) may refer to a parameter eg:if_eth0
. The best way to tell what it expects is to read the contents of the plugin. Some of the better constructed plugins may even help you. eg:/usr/share/munin/plugins/mysql_ suggest
outputs a list of suitable suffixes.Configure remote access
The master polls the node for data so, if you're using a remote master, don't forget to grant it access via
/etc/munin/munin-node.conf
on the node.Configure the master
You can run master and node on the same host. Or you can put the master someplace else - which is advisable if you're watching a busy production server as generating the graphs every few minutes is quite a bit of work.
I got that going no problem using the standard documentation and adding nodes into
/etc/munin/munin.conf
.To see how the polling is going keep an eye on
/var/log/munin/munin-update.log
. When data from a new plugin is first seen you should get a bunch of log entries recording the construction of a new rrd database:This is also the place to find warnings and errors relating to the incoming data.
One final gotcha is that, by default, the node data collection only happens every two minutes, and the remote polling only happens every 5 minutes. Additionally it can take 60 seconds to turn the data into graphs, and finally the first entry is possibly a single data point which isn't visible. So, unless you fiddle with the cycle times, it might be 15 minutes between getting the plugin correctly configured and when data appears on your graph.
I'm out of steam. If this doesn't help someone else, it will at least help me remember what the heck i've done.
The final result is great infoporn...
Remove a plugin from your
munin-node
configuration and that plugin's graphs will be removed.You install the munin plugins for those products on the
munin-node
.