How to set up Munin monitoring

Munin is a lightweight and simple monitoring system. It can gather statistics from different networked machines, including NAS devices like DNS-323. Munin consists of a master that collects, stores and visualizes data from a number of nodes, and this tutorial describes how to configure DNS-323 to act as a Munin node.

Munin node

This article assumes that ffp is already installed on the device.

You should login to the device either over ssh or telnet, cd to a directory on a filesystem with enough free space and download the funpkg packages (currently hosted on the forum)

# chdir /mnt/HD_a2
# wget http://www.inreto.de/dns323/fun-plug/0.5/extra-packages/perl/perl-5.10-2.tgz
# wget -O munin-node-1.4.5-2.tgz http://dns323.kood.org/forum/attachment.php?item=662
# wget -O perl-mod-Net-Server-0.99-1.tgz http://dns323.kood.org/forum/attachment.php?item=661

When the download is complete the packages should be installed

# funpkg -i perl-5.10-2.tgz
Installing package perl-5.10-2 ...
# funpkg -i perl-mod-Net-Server-0.99-1.tgz
Installing package perl-mod-Net-Server-0.99-1 ...
# funpkg -i munin-node-1.4.5-2.tgz
Installing package munin-node-1.4.5-2 ...
[...]
Executing install script for munin-node-1.4.5-2 ...

Munin has a modular architecture, and information about individual components of a system is provided by plugins. None are enabled by default, but there is an auto-detection mechanism available that can guess which plugins might be useful on a given machine. You can either enable plugins manually by symlinking scripts from /ffp/lib/plugins/cpu to /ffp/etc/munin/plugins/ or rely on Munin to do this automatically using

# perl /ffp/sbin/munin-node-configure --shell | sh -x
# The following plugins caused errors:
[...]
+ ln -s /ffp/share/munin/plugins/cpu /ffp/etc/munin/plugins/cpu
+ ln -s /ffp/share/munin/plugins/diskstats /ffp/etc/munin/plugins/diskstats
+ ln -s /ffp/share/munin/plugins/entropy /ffp/etc/munin/plugins/entropy
+ ln -s /ffp/share/munin/plugins/forks /ffp/etc/munin/plugins/forks
+ ln -s /ffp/share/munin/plugins/fw_packets /ffp/etc/munin/plugins/fw_packets
+ ln -s /ffp/share/munin/plugins/http_loadtime /ffp/etc/munin/plugins/http_loadtime
+ ln -s /ffp/share/munin/plugins/interrupts /ffp/etc/munin/plugins/interrupts
+ ln -s /ffp/share/munin/plugins/iostat /ffp/etc/munin/plugins/iostat
+ ln -s /ffp/share/munin/plugins/iostat_ios /ffp/etc/munin/plugins/iostat_ios
+ ln -s /ffp/share/munin/plugins/irqstats /ffp/etc/munin/plugins/irqstats
+ ln -s /ffp/share/munin/plugins/load /ffp/etc/munin/plugins/load
+ ln -s /ffp/share/munin/plugins/memory /ffp/etc/munin/plugins/memory
+ ln -s /ffp/share/munin/plugins/nfs4_client /ffp/etc/munin/plugins/nfs4_client
+ ln -s /ffp/share/munin/plugins/nfsd /ffp/etc/munin/plugins/nfsd
+ ln -s /ffp/share/munin/plugins/nfsd4 /ffp/etc/munin/plugins/nfsd4
+ ln -s /ffp/share/munin/plugins/open_files /ffp/etc/munin/plugins/open_files
+ ln -s /ffp/share/munin/plugins/open_inodes /ffp/etc/munin/plugins/open_inodes
+ ln -s /ffp/share/munin/plugins/proc_pri /ffp/etc/munin/plugins/proc_pri
+ ln -s /ffp/share/munin/plugins/processes /ffp/etc/munin/plugins/processes
+ ln -s /ffp/share/munin/plugins/swap /ffp/etc/munin/plugins/swap
+ ln -s /ffp/share/munin/plugins/threads /ffp/etc/munin/plugins/threads
+ ln -s /ffp/share/munin/plugins/uptime /ffp/etc/munin/plugins/uptime
+ ln -s /ffp/share/munin/plugins/users /ffp/etc/munin/plugins/users

Munin plugins are in fact simple scripts with plain-text output that can be executed using munin-run

# perl -T /ffp/sbin/munin-run cpu      
user.value 6639837
nice.value 0
system.value 6932479
idle.value 186026521
iowait.value 2634360
irq.value 8
softirq.value 209867
steal.value 0

The 'df' script (/ffp/share/munin/plugins/df) not work properly because the busybox df command is less about. Change the original line to the repaired line:

The original line:

my $dfopts = "-P -l".join(' -x ',('',split('\s+',$exclude))); 

The repaired line

my $dfopts = "-k | grep -v -e /dev/loop0 -e rootfs";

or use this script:

#!/ffp/bin/sh

cp /ffp/share/munin/plugins/df /ffp/share/munin/plugins/df_bak
cat /ffp/share/munin/plugins/df_bak | sed 's/my \$dfopts = "-P -l".*$/my $dfopts = "-k | grep -v -e \/dev\/loop0 -e rootfs";/' > /ffp/share/munin/plugins/df
ln -s /ffp/share/munin/plugins/df /ffp/etc/munin/plugins
killall -9 munin-node
/ffp/start/munin-node.sh restart

Be aware that some plugins may require additional dependencies.

A newly installed Munin node accepts only localhost connections, so you should modify /ffp/etc/munin/munin-node.conf to allow at least incoming connections from the Munin master

allow ^127\.0\.0\.1$
allow ^191\.168\.1\.2$

Of course you should substitute 191.168.1.2 with the IP of the Munin master. The addresses look weird because the allow directives takes Perl regular expressions, and dots have to be escaped.

The next step is to enable the munin-node daemon

# chmod a+x /ffp/start/munin-node.sh
# /ffp/start/munin-node.sh start

In order to verify that the node is up and running you can connect to it and invoke a command which lists all available plugins

# nc localhost 4949
# munin node at localhost
list << YOU SHOULD TYPE THIS AND PRESS ENTER
cpu entropy forks fw_packets http_loadtime interrupts ...

You can try the same command from the Munin master to make sure that it can connect to the node.

For additional security munin-node can be run from inetd or tunnelled over SSH, but this is beyond the scope of this tutorial.

Munin master

When the node is up and running all that you need is a master that will collect, store and visualize the data.

The Munin master should be installed on a server that is always on and has network access to all the nodes. Most decent Linux distributions should have a Munin package available, and if not you should follow the documentation.

In case of Debian-based distributions the installation is as simple as

$ sudo apt-get install munin

Then you should edit the /etc/munin/munin.conf configuration file and add a following entry

[dns323]
    address 192.168.1.3
    use_node_name yes

Instead of dns323 you can put any other string that identifies the device, for example its hostname, and instead of 192.168.1.3 you should provide the IP address of the node.

There is no need to restart anything, the Munin master is a process executed from cron, not a daemon. You just have to wait about 5 minutes for the next cron invocation and check the HTML output by opening file:///var/cache/munin/www/index.html in a browser.

This directory contains static HTML output that can be either viewed locally or served using any HTTP server. In case of problems the master logs are available at /var/log/munin/munin-update.log, and the logs of a node at /ffp/var/log/munin/munin-node.log.

You can see a sample output from the Munin master at the demo installation. If you want to learn more about Munin, spend some time reading the documentation.


Navigation

Personal Tools