Monitoring using Collectd

written on Sunday, December 19, 2010

So. I've gotten my hands on a nice little Sheevaplug Server running Debian Squeeze, and I handily had a small network monitoring job to do...

First off, I tried out trusty old Munin, but the puny ARM processor couldn't quite keep up with the constant graph-generation. As I had also run into a few other of Munins limitations in past projects, I decided it was time to try something else.

Enter collectd

I had previously discarded Cacti, Nagios and friends for being overly complex for my uses; I just use the collected data to assert what has happended after the fact. (And, hopefully, fix it before it happens again.)

Then various sources suggested to take a look at collectd...

Up front, collectd, has only one minor drawback IMHO; it does not come with a built-in front-end for viewing the collected data. (I guess thats the collect-part of collectd).

Installing & Setting up

Install the packages and get going:

sudo apt-get install collectd

Before you start up collectd, you should fix the configuration file to your liking; namely, it defaults to collect data every tenth second, which you might want to change a bit. Take a look in /etc/collectd/collectd.conf:

# Poll once a minute
Interval 60

Please note that you can't (easily) change this interval after you started the server, as it will be "hard-coded" into the collected RRD-files.

It's also in this file you set up what the daemon should actually collect. As to testing that our network actually is alive, I want to ping the outside world:

# Uncomment the appropriate 'LoadPlugin' lines:
LoadPlugin ping

# Later in the file, there's the individual plugin setups:
<Plugin ping>
    Host "sbhr.dk"      # My own web server.
    Host "192.168.1.1"  # The local gateway
    # I leave the default as-is
</Plugin>

Not it's time to start the server:

sudo service collectd start

(Also, you'll have something besides blank graphs to see later...)

Viewing the output

After browsing the front-end list, I randomly decided on using collectd-web. I chose to go with the trunk:

mkdir Source
cd Source
git clone https://github.com/httpdss/collectd-web.git
cd collectd-web

Before moving on, a few packages are needed, though (and check it's all there by running the check_deps.sh-script.):

sudo apt-get install librrds-perl libjson-perl liburi-perl libhtml-parser-perl
./check_deps.sh

If the latter returns all-OK, then you can use the runserver.py-script to take it for a spin:

./runserver.py

It will run a small webserver on the machines' port 8888, where you can watch it work:

collectd-web screenshot

While I had some ideas about using Nginx and spawn-fcgi to run the above CGI-scripts, I've decided to settle for running the runserver.py in screen:

screen -d -m ./runserver.py

Done!

This entry was tagged Debian, collectd and monitoring