First steps with collectd
This short and most likely incomplete article should guide the novice user through the process of getting collectd to work. Pointers to the manpages are provided where appropriate.
Since no OS is like the other, I'll talk about my Linux Distribution, Debian, here. So the location of some files or commands to install packages may differ for your system.
Getting the daemon
First, you will need to get the binaries somehow. There are basically two choices: Find a binary package or compile yourself.
Get a binary package
For many Linux distributions there are binary packages. There is a package in Debian Etch, for example, though I will talk about the version 4.1.2 here, which is different from version 3.10.4 included in Etch.
Compiling the sources
If there is no binary package for your distribution, or the one existing is outdated, you can compile the sources. For that you will need to install the usual C-compiler (most likely called "gcc"), linker, headers of required libraries and so on:
After installing the build dependencies, you need to get and unpack the sources:
# wget http://collectd.org/files/collectd-x.y.z.tar.bz2
# tar jxf collectd-x.y.z.tar.bz2
# cd collectd-x.y.z
Now configure the sources with the usual:
After the configure-script is done it will display a
summary of the libraries it has found (and not found) and which plugins
are enabled. Per default, all plugins whose dependencies are met are
enabled. If a plugin you want to use is missing install the required
development package and run configure again.
Last but not least: Compile and install the program. Per default it
will be installed to
/opt/collectd.
# cd /opt/collectd/
Configuration
The configuration will lie in
<prefix>/etc/collectd.conf. It's manpage is
collectd.conf(5).
Open the file and pay particular attention to the
LoadPlugin lines.
Loading plugins
The LoadPlugin lines that are commented out are plugins
that have not been built. Commenting them in will not work, because the
plugin does not exist. But, you may want to disable some plugins, for
example the csv-plugin will not be of interest for people
who just want to get pretty graphs. Actually, we recommend to comment
out all plugins and then just comment in the ones you
specifically want to have.
The following is a list of the very basic plugins and a short description:
| Name | Type | Description |
|---|---|---|
logfile |
logging | Writes log messages to a file or standard output |
rrdtool |
output | Writes data to RRD-files |
csv |
output | Writes data to CSV-files |
cpu |
input | Collects CPU usage |
memory |
input | Collects memory usage |
interface |
input | Collects traffic of network interfaces |
Setting options
The Interval setting sets how often values are read.
You should set this once and then never touch it again. If you do,
you will have to delete all your RRD-files or know
some serious RRDTool-magic!
Some plugins take an additional configuration. Of interest are the
logfile- and rrdtool-plugin. Before setting
anything explicitly, please read the relevant part of the collectd.conf(5)
manpage.
There are no undocumented options. The
rrdtool-plugin is especially prone of mis-configuration,
please read the manpage especially careful when configuring this
plugin.
Starting the daemon
If you're done configuring, you need to (re-)start the daemon. If
you installed a binary package there should be an
init-script somewhere. Under Debian, the command would
be:
Alternatively you can start the daemon "by hand". This is done by executing:
Some plugins require root privileges to work properly. If you're missing graphs and/or see error messages that indicate insufficient permissions, restart collectd as root.
The daemon should now collect values using the "input" plugins you've loaded and write them to files using the "output" plugin(s). Any problems or interesting behavior is reported using the "log" plugin(s).
Creating graphs
First off: It is not collectd's focus to generate
graphs! The focus is to collect the values and write it to
files or send it to another host over a network. But since we have to
visualize the data somehow, too, we have been nice enough to throw a
script that's "good enough for us" into the
contrib/ directory. This script, however, is not part of
collectd and not supported by us. It just
happens to work sometimes.
That being said, here's how it's installed: Copy the script to a
location where your webserver expects CGI scripts. Under Debian that's
/usr/lib/cgi-bin/. The script expects it's configuration
in /etc/, a sample configuration file is included in the
tarball, too. If you installed the Debian package the script and it's
configuration are found in
/usr/share/doc/collectd/examples/.
# cp contrib/collection.conf /etc/
Now check that the paths in the configfile,
/etc/collection.conf, are right for your setup and point a
browser to http://localhost/cgi-bin/collection.cgi.
If that doesn't work, check the permissions of the two files, especially that the script is executable and the configuration is readable by the webserver user. If you still have problems please read this howto on CGI scripts. Good luck ;)
