Command disabled: revisions

collectd

Collectd collects data from your system (CPU, load, etc) and the software it's running (e.g. Apache, MySQL).

Installation

Just follow the instructions on the collectd wiki. The wiki assumes you're using a Debian-based system, but they're advising you to compile from source code anyway. I got collectd to work on my Debian-based systems by simply using apt-get:

apt-get install collectd

You may also need to install libcurl (used by collectd's Apache plugin):

apt-get install curl

Collectd's core task is to collect data, but they also provide a simple graphics generator, based on perl scripts. Here's what you've got to install to get it working:

apt-get install librrds-perl libconfig-general-perl libhtml-parser-perl  libregexp-common-perl

Compiling collectd

Make sure your system meets all the requirements. Each collectd plugin may also have its own requirements. See the README.

On my Ubuntu 6 system, I also had to install libcurl3-dev. To make sure that your system meets the requirements, use the –enable switch:

./configure --enable-apache --enable-mysql

Configuration

Now it's time to configure collectd. Use a text editor (e.g. nano) to edit /etc/collectd.conf. An important thing to get right immediately, is the Interval directive. If you change this setting afterward, you apparently have to completely reinstall collectd or remove all its data files. The default, 10 seconds, is okay.

Apache Plugin

To use the Apache plugin, you have to configure Apache first: collectd uses mod_status. Debian-based systems usually have mod_status installed already. All you have to do, is tell Apache you want to use it. Edit the /etc/apache2/apache2.conf file by adding:

ExtendedStatus on
<Location /mod_status>
  SetHandler server-status
</Location>

Don't forget to restart Apache after saving the apache2.conf file.

Now you've got to uncomment the load directive for the plugin in the /etc/collectd.conf file:

LoadPlugin apache

And add some configuration for the Apache plugin in the /etc/collectd.conf file:

<Plugin apache>
        URL "http://localhost/mod_status?auto"
#       User "www-user"
#       Password "secret"
#       VerifyPeer false
#       VerifyHost false
#       CACert "/etc/ssl/ca.crt"
</Plugin>

Please be warned that your Apache server info, as printed by http://localhost/mod_status, will be accessible by whatever name your localhost has to the outside world. E.g., if your system is called mymachine.com, then Apache will happily ouput its status through mymachine.com/mod_status.

MySQL Plugin

Just create a MySQL user called collectd, with no privileges at all. Restrict this user to the localhost and make up a good, strong password.

Again, uncomment the load directive in the /etc/collectd.conf file:

LoadPlugin mysql

And configure the plugin:

<Plugin mysql>
        Host "localhost"
        User "collectd"
        Password "secret_password"
#       Database "db_name"
</Plugin>

Now (re)start the daemon: /etc/init.d/collectd restart, or: /opt/collectd/sbin/collectd.

Creating Graphs

Copy the directory /usr/share/doc/collectd/examples/collection3 to a place where your cgi scripts are running, e.g. /home/onno/cgi-bin. Change the ownership of the collection3 directory:

chown -R www-data:www-data collection3

You can now access your graphs at http://yoursite.com/cgi-bin/collection3/bin/index.cgi.

Please note that the graphing scripts seem to require at least Perl 5.10. Ubuntu 6.06 carries Perl 5.8.7.

Visage

Visage is a Ruby / Sinatra based tool which uses collectd's rrdtool plugin to plot data in graphs.

The Visage GitHub site explains the installation and configuration. If you run into trouble with Sinatra, check this blog.

Running and Securing Collectd

To run collectd, simply use: /etc/init.d/collectd restart, or /opt/collectd/sbin/collectd. If you've installed collectd through apt-get, it's going to start automatically on reboot.

You can secure access to the graphs by simply securing the directory through Apache: securing_a_web_directory_with_apache.


Personal Tools