Monitor NetBSD with Munin

       557 words, 3 minutes

This article is about monitoring NetBSD with Munin, using munin-node. I already configured a running munin-server on OpenBSD ; so I could simply use it to graph my NetBSD metrics. Here’s, we’ll go through installing both node and server on NetBSD.

ATTOW, pkgsrc provides Munin v1.3.x. So I’m gonna build munin-node from pkgsrc-wip. Once this is done, proceed to installation and configuration on the node to be monitored:

# cd /usr/pkgsrc/wip/munin-node
# make install

There are missing Perl bits in the munin-node package. A quick and (really) dirty way of fixing it is by doing:

# cd /usr/pkgsrc/wip/munin-node/work/.destdir
# for FIC in \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/OS.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Service.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Server.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Config.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Session.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Logger.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Utils.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/SNMPConfig.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Configure/Plugin.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Configure/HostEnumeration.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Configure/PluginList.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Configure/Debug.pm \
usr/pkg/lib/perl5/site_perl/5.12.0/Munin/Node/Configure/History.pm \
usr/pkg/man/man3/Munin::Node::Config.3 \
usr/pkg/man/man3/Munin::Node::Server.3 \
usr/pkg/man/man3/Munin::Node::Service.3 \
usr/pkg/man/man3/Munin::Node::OS.3 \
usr/pkg/man/man3/Munin::Node::Configure::HostEnumeration.3 \
usr/pkg/man/man3/Munin::Node::Configure::PluginList.3 \
usr/pkg/man/man3/Munin::Node::SNMPConfig.3 \
usr/pkg/man/man3/Munin::Node::Session.3 \
usr/pkg/man/man3/Munin::Node::Logger.3 \
usr/pkg/man/man3/Munin::Node::Configure::Debug.3 \
usr/pkg/man/man3/Munin::Node::Utils.3 \
usr/pkg/man/man3/Munin::Node::Configure::Plugin.3 \
usr/pkg/man/man3/Munin::Node::Configure::History.3 \
; do
tar cpf - $FIC | tar xpf - -C /
done

Configure the rc files:

# vi /etc/rc.conf
(...)
munin_node=YES
(...)
# vi /etc/rc.conf.local
(...)
/usr/pkg/share/examples/rc.d/munin-node start
(...)

Configure the log rotation process:

# vi /etc/newsyslog.conf
(...)
/var/log/munin/munin-node.log   munin:munin 644 7 *    24   Z
(...)

Modify munin-node’s configuration file:

--- /usr/pkg/share/examples/munin/munin-node.conf       2011-07-26 06:02:22.000000000 +0200
+++ /usr/pkg/etc/munin/munin-node.conf  2011-07-26 06:18:48.000000000 +0200
@@ -4,5 +4,5 @@

 log_level 4
-log_file /usr/pkg/log/munin/munin-node.log
+log_file /var/log/munin/munin-node.log
 pid_file /var/run/munin/munin-node.pid

@@ -10,6 +10,6 @@
 setsid 1

-user root
-group root
+user munin
+group munin

 # Regexps for files to ignore

The wip package is really badly released… The perl reference in scripts is incorrectly set. That being said, “shut up and code” (c). Fix every scripts:

# vi /usr/pkg/bin/munindoc /usr/pkg/sbin/munin-node /usr/pkg/sbin/munin-node-configure /usr/pkg/sbin/munin-run
#!/usr/pkg/bin/perl
(...)

Automagically detect what can be monitored:

# perl /usr/pkg/sbin/munin-node-configure --shell

Select the counters and/or use “|sh” to install the plugins.

You can check if everything would work nice running:

# sudo -u munin munin-run cpu

Once munin-node is configured and running, you shalt proceed to the munin-master part. First of all, build the package from wip/munin-master and install it.

Review the configuration editing /usr/pkg/etc/munin/munin.conf:

--- /usr/pkg/share/examples/munin/munin.conf    2011-07-26 02:46:51.000000000 +0200
+++ /usr/pkg/etc/munin/munin.conf       2011-07-26 06:51:13.000000000 +0200
@@ -6,8 +6,8 @@
 # defaulted to the values you see here.
 #
-# dbdir        /var/munin
-# htmldir /usr/pkg/www/munin
-# logdir /usr/pkg/log/munin
-# rundir  /var/run/munin
+dbdir  /home/munin/db
+htmldir        /home/munin/www
+logdir /var/log/munin
+rundir /var/run/munin
 #
 # Where to look for the HTML templates

Set your system up according to the package MESSAGE:

===========================================================================
$NetBSD: MESSAGE,v 1.3 2006/06/09 13:25:22 he Exp $

You can start the collection of statistics and production of graphs by
installing a crontab for the munin user of the form

*/5 * * * * /usr/pkg/bin/munin-cron

You may need to give munin a valid shell to do so.


You may also want to add lines like

/var/log/munin/munin-graph.log  munin:munin 644 7 *    24   Z
/var/log/munin/munin-html.log   munin:munin 644 7 *    24   Z
/var/log/munin/munin-limits.log munin:munin 644 7 *    24   Z
/var/log/munin/munin-update.log munin:munin 644 7 *    24   Z

to your /etc/newsyslog.conf file to have the logs rotated.

===========================================================================

I used root’s crontab, specifying “sudo -u munin -c daemon /usr/pkg/bin/munin-cron” and configuring login.conf.

Also, you can use the native NetBSD Web server to display the Web pages. In my configuration, I just had to:

# vi /etc/inetd.conf
(...)
http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /home/munin/www
(...)
# pkill -HUP inetd

That’s All Folks!