Monitoring with Munin
Join the DZone community and get the full member experience.Join For Free
one of the things i’m massively fond of when it comes to systems administration, is logging and monitoring. i love
, and still prefer it over
. i think the main reason is that it allows plugins to be configured with absolutely no browser interaction.
creating a new graph on cacti and zabbix both require a considerable number of clicks. it’s easy to install new munin plugins with things like puppet . so.. munin. let’s take a bit of a closer look.
there’s two parts to a munin installation. munin server , and munin-node .
munin server doesn’t really do the cool stuff, just data aggregation and graph creation.
i’ve included an example munin.conf here .
there’s only a couple of quirks here.
i’ve found for the majority of installations, that you can leave the vast majority of settings in-place as they are from the version installed by apt / yum / $package_manager_of_your_choice.
so, the actual munin documentation suggests that use_node_name is a dodgy thing to do, but it’s actually pretty useful, especially when you’re defining snmp hosts.
use_node_name tells the not to grapher to use the hostname that’s in [brackets], but instead to use the name in the connection banner (you can see this yourself, once munin is running, to telnet (or nc) to localhost:4949, and the line “#munin node at <your host>”)
snmp hosts.. are without doubt the coolest thing that munin can do. by default, the auto-configuration of snmp hosts will allow you to monitor some interesting things about routers, switches and windows hosts. so.. the only major quirk about this, is that because the snmp plugins run on one of your munin-node instances, so you have to set that as the address in the host definition. in the example, i’ve done this on the munin server.
munin-node. very extensible, but as far as config goes, the default configuration that comes in the installation is more than capable.
if you have multiple munin-servers, or want to retrieve munin-plugin data from nagios servers, then you can add multiple “allow” regex lines.
so.. munin plugins. this is the really cool stuff.
basically, you need to handle two things, “ config ” and “ run ” modes.
munin-run is the thing that handles the plugin, and runs “your-plugin config”. this is what defines the format of the rrd files that munin uses to generate graphs. ok, so let’s look at a simple munin plugin. i think we’ll monitor... the number of files in /tmp (well, why not?)
if we run that with python tmp_files config, then we get:
graph_title number of files in /tmp graph_category system graph_args --base 1000 -l 0 graph_vlabel files files.info the number of files in /tmp files.warning 10 files.critical 120 files.min 0 files.type gauge files.label files
and if we run it without “config”, we get:
so, that works. :)
now if we copy that into /usr/share/munin/plugins, and chmod +x, and symlink it into /etc/munin/plugins.. and restart munin-node..
$ sudo mv tmp_number.py /usr/share/munin/plugins/tmp_number $ sudo ln -s /usr/share/munin/plugins/tmp_number /etc/munin/plugins/tmp_number $ sudo chmod a+x /usr/share/munin/plugins/tmp_number $ sudo /etc/init.d/munin-node restart * stopping munin-node [ ok ] * starting munin-node [ ok ] $ munin-run tmp_number files.value 18
cool. right.. now that’s done, and munin-node’s been restarted, all we have to do is wait a while, and the new graph will get created. this can take a while, 5-10 minutes is a good guesstimate, but it can be longer.
this is the graph produced by the plugin:
if you find that you’ve waited ages, and still have no graphs, take a look at /var/log/munin on the munin-server and munin-node. there’s plenty of non-cryptic logging there, and it’s all pretty self explanatory.
Opinions expressed by DZone contributors are their own.