[collectd] The new config file and how it works

Florian Forster octo at verplant.org
Wed Dec 14 15:49:43 CET 2005


Hello :)

On Wed, Dec 14, 2005 at 01:59:42PM +0100, Jan Huijsmans wrote:
> This is no rocket science, just take the easy way out.

I can't say that I dislike easy solutions, but I dislike reinventing the
wheel _again_. Since it's such a common task there should be more
libraries doing that than there are web-forums.. Oddly enough that's not
the case..

Anyways, as I wrote yesterday or the day before that: I went for
`libconfig' which worked pretty well.. The config file implemented so
far does exactly what I want it to do: Pass configuration items to
modules, if they request them.

I'll explain how this (will) work for users first and for developers
after that:

=== USERS ===

The config file is named `$prefix/etc/collectd.conf' and looks something
like this:
-- 8< --
 <Mode Client>
   LoadModule cpu
   LoadModule disk
   ...
 </Mode>

 <Mode Server>
   LoadModule traffic
   LoadModule ping
   ...
 </Mode>

 <Mode Local>
   LoadModule swap
   ...
 </Mode>

 <Module ping>
   Host google.com
   Host akamai.com
 </Module>
-- >8 --

Only modules with a `LoadModule' directive will be loaded. Some modules
may require additional arguments which can be supplied using a
`<Module ...>' section. The `ping' module is the only module using this
right now.

=== DEVELOERS ===

Besides a call to `plugin_register' modules/plugins may call
`cf_register' (cf == configfile) which is defined in `configfile.h'. The
arguments passed to this function are
- a module name
- a callback function
- a list of `configuration variables'
- the length of that array

For a more detailed description read `configfile.h' which I have
documented close to excessively..
<http://svn.verplant.org/filedetails.php?repname=collectd&path=%2Fbranches%2Fcollectd-configfile%2Fsrc%2Fconfigfile.h&rev=0&sc=0>

Right now the `init' callback is called _after_ the `config' callback,
but that might change in the future, better don't depend on it.

Introducing a second `register' function has the big advantage that
plugins that don't need any extra configuration (all but `ping' so far)
don't have to be touched at all..

I'll merge this branch to the trunk soon which may break stuff.. Just so
you know..

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20051214/3476c001/attachment.pgp


More information about the Collectd mailing list