How To: Install munin-node on cPanel DNS Only

Mon, 28/01/2013 - 09:55 -- James Oakley

This blog has posts on a number of themes, and this one is technology related; for the rest of you, I shall see you later on. If you don't understand the title of this post, then it's probably not written with you in mind!

Edit: cPanel 11.36 introduces RPM support for Munin, so this issue may disappear. However the approach below may also help those who had previously installed Munin from EPEL, but are now getting errors such as "from install of cpanel-perl-514-munin-1.4.7-2.cp1136.i386 conflicts with file from package munin-node-1.2.5-2.el5.rf.noarch" when upgrading to cPanel 11.36.

The problem:

You have a server running cPanel DNS Only on top of Centos 6. You wish to install munin-node.

First attempt:

Try

yum install munin-node

That doesn't work, because the default Centos repositories don't have munin-node on.

Second attempt:

So you add EPEL. If I have to tell you how to do this, again - perhaps this post isn't for you. But you'd run

rpm -Uhv http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

and a few extra steps to verify GPG keys etc.

Note: That is the latest release of EPEL on the version 6 branch (for Centos 6, or its siblings), but you'd obviously want to use the rpm file for Centos 5 if you're running Centos 5, and you'd need the latest version if 6.8 is no longer the latest.

You try again, and it fails becaus there are Perl modules as dependencies, but they aren't available in the repository.

Third attempt:

This is because cPanel explicitly excludes certain packages from yum, so you need to edit /etc/yum.conf, and comment out the 

exclude=apache* bind-chroot ...

line near the top. This time, munin-node does install successfully. But when you run

/etc/init.d/munin-node start

you get

Starting Munin Node: Can't locate Munin/Common/Defaults.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.8/i686-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl) at /usr/sbin/munin-node line 32.
BEGIN failed--compilation aborted at /usr/sbin/munin-node line 32.

What now?

Stuck

The issue is something to do with the way cPanel installs it's own version of Perl, but I've not been able to dig any deeper than that. I know that, because a vanilla installation of Centos 6 successfully installs munin-node from the EPEL repository, and the service starts fine. Google got me nowhere - a few people on forums / newsgroups seemed to have a similar issue, but there were no clear solutions.

There is a similar issue with installing on top of full cPanel, but there is a work-around there that is easy - use the plugins manager in WHM to install Munin, then if you don't want the master version of Munin running you simply comment out the cron entry that runs it every 5 minutes.

The Solution

Install munin-node from source. This requires a bit of care to get your installation looking like what you might be used to if you've installed in the past from the cPanel interface.

Disclaimers

Disclaimer 1: What you do on your server is your responsibility. I'm offering out some advice here in the hope it will help you to find the right solution for you. If you don't understand the steps I'm outlining below, then you probably shouldn't be trying them!

Disclaimer 2: This is not a guide on how to configure munin, write plugins, set munin up to run as a client/server combination, or anything like that. All of that is well documented elsewhere on the internet, so I'm only trying to help with the one task of getting a working installation

Preliminaries: Perl Modules

According to the Munin documentation, munin-node needs three Perl packages as essentials. They are:

  • Net::Server
  • Net::Server::Fork
  • Time::HiRes

Actually, Net::Server::Fork comes with Net::Server, so we just have two installations to perform.

You could do this with

cpan install Net::Server

but, let's do it from source too, because then we know what we've done at each point. Also, if (like me) you're trying this on a low-RAM box, you'll probably find cpan falls over anyway.

Find the modules on http://search.cpan.org. At time of writing that takes you to http://search.cpan.org/~rhandom/Net-Server-2.007/lib/Net/Server/Fork.pm and http://search.cpan.org/~zefram/Time-HiRes-1.9725/HiRes.pm

Download, untar, make, make test, install. So, again for the versions of the modules at time of writing:

cd /usr/local/src
wget http://search.cpan.org/CPAN/authors/id/R/RH/RHANDOM/Net-Server-2.007.tar.gz
tar -xvzf Net-Server-2.007.tar.gz
cd Net-Server-2.007
perl Makefile.PL
make
make test
make install
cd ..
wget http://search.cpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Time-HiRes-1.9725.tar.gz
tar -xvzf Time-HiRes-1.9725.tar.gz
cd Time-HiRes-1.9725
perl Makefile.PL
make
make test
make install
cd ..
rm -rfv Time-HiRes-1.9725* Net-Server-2.007*

Download and Install

Now download munin-node. You probably want the latest version from their SourceForge location.

untar, and go to edit Makefile.config

You need to set the following variables to make your installation resemble what you would have got through yum

CONFDIR = /etc/munin
BINDIR = /usr/bin
SBINDIR = /usr/sbin
MANDIR = /usr/share/man
LIBDIR = /usr/share/munin
DBDIRNODE = /var/lib/munin
LOGDIR = /var/log/munin

You then need to use useradd to create a new user called munin.

Then run

make
make install-common-prime install-node-prime install-plugins-prime

This is all assuming that you only want to run munin-node. If you wanted to run the munin master as well, the last step would simply be

make install

but you would need extra Perl dependencies, and there'd be a few more variables to tweak.

Finally, don't forget to alter /etc/munin/munin-node.conf, to let your munin master have access to this node.

Add a service controller

You probably want to be able to control your service using the service command, but this installer puts no entry in /etc/init.d

So you need to create a file called /etc/init.d/munin-node, and put the code below in it. It needs chmod +x running on it.

#! /bin/sh
#
# munin-node Control the Munin Node Server (formerly Linpro RRD client)
#
# chkconfig: 2345 90 10
# description: munin node agents
# processname: munin-node
# config: /etc/munin/munin-node.conf
# pidfile: /var/run/munin/munin-node.pid

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0
PROCNAME=munin-node

mkdir -p /var/run/munin 2>/dev/null
chown munin /var/run/munin

# See how we were called.
case "$1" in
  start)
    echo -n "Starting Munin Node: "
    /usr/sbin/munin-node &
    sleep 1
    pkill -0 $PROCNAME
    RETVAL=$?
    if [ $RETVAL -eq 0 ]
    then
      echo_success
      touch /var/lock/subsys/munin-node
    else
      echo_failure
    fi
    echo
    ;;
  stop)
    echo -n "Stopping Munin Node agents: "
    kill $(cat /var/run/munin/munin-node.pid)
    RETVAL=$?
    if [ $RETVAL -eq 0 ]
    then
      echo_success
      rm -f /var/lock/subsys/munin-node
    else
      echo_failure
    fi
    echo
    ;;
  status)
    status $PROCNAME
    RETVAL=$?
    ;;
  restart|reload)
    $0 stop
    $0 start
    RETVAL=$?
    ;;
  *)
    echo "Usage: munin-node {start|stop|status|restart}"
    exit 1
esac

exit $RETVAL

One little gotcha:

The plugin state files for this installation go in /var/lib/munin/plugin-state/{username} as opposed to /var/lib/munin/plugin-state (which is where they go on an installation through yum)

Blog Category: 

Add new comment

Additional Terms