[image of the Head of a GNU] [ English ]

In order to extend cfengine's action-sequence, you can write your own modules.
Web traffic watcher and example
Load average watcher and example
If the regular mechanisms for setting classes do not produce the results you require for your configuration, you can write your own routines to concoct the classes of your dreams. Plugin modules are added to cfengine programs from within the actionsequence, (see Reference manual). They allow you to write special code for answering questions which are too complex to answer using the other mechanisms above. This allows you to control classes which will be switched on and the moment at which your module attempts to evaluate the condition of the system.

Modules must lie in a special directory defined by the variable moduledirectory. They must have a name of the form module:mymodule and they must follow a simple protocol. Cfengine will only execute a module which is owned either by root or the user who is running cfengine, if it lies in the special directory and has the special name. A plug-in module may be written in any language, it can return any output you like, but lines which begin with a + sign are treated as classes to be defined (like -D), while lines which begin with a - sign are treated as classes to be undefined (like -N). Any other lines of output are cited by cfengine, so you should normally make your module completely silent. Here is an example module written in perl. First we define the module in the cfengine program:


   moduledirectory = ( /local/cfengine/modules )

   actionsequence = (

Note that the class definitions for the module can also be defined in as AddInstallables, if this is more convenient. Next we write the plugin itself.
# module:myplugin

  # lots of computation....

if (special-condition)
   print "+specialclass";
Modules inherit the environment variables

[ English ]

Return to GNU's home page.

Please send FSF & GNU inquiries & questions to There are also other ways to contact the FSF.

Please send comments on these web pages to, send other questions to

Copyright (C) 2001 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

Updated: $Date: 2001/07/20 07:06:27 $ $Author: brett $