1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
PMACCTD PLUGIN WRITING HOW-TO
SHORT OVERVIEW
the pmacct plugin architecture is thought to allow people that need
their own backend to implement it without knowing too much of core
collectors functionalities and independently by other plugins.
Below are listed a few steps to hook your plugin in pmacct; pmacct
is also extremely open to new ideas, so if you wish to contribute
your work, you are the most welcome.
- minor hacks to configure.in script following the example of what
has been done there for mysql plugin; same goes for requirements
like paths to headers or libraries. By making use of the PLUGINS
variable, it will not be required to touch the "src/Makefile.am"
script. Definitions in configure.in (ie. AC_DEFINE(WITH_MYSQL, 1))
whose existence can be checked via compiler preprocessor is an
easy way to propagate user configuration choices at compilation
time.
- [OPTIONAL] If the plugin needs to take configurable values, this
can be achieved by defining configuration handlers (pmacct-data.h,
cfg_handlers.h, cfg_handlers.c) and declaring config variables to
deliver configured values to the plugin (cfg.h, struct configuration).
If command-line parameters are also required, some getopt() related
code needs to be dealt with (pmacct-defines.h and ie. pmacctd.c,
nfacctd.c, sfacctd.c and uacctd.c).
- Define the new plugin in pmacct; this can be done by adding an
entry to the plugin_types_list[] array (pmacct-data.h). An entry
consists of two fields: an id string and a pointer to a function
to be called. The first is the string which will be used to call
the plugin from within the configuration or command-line. The
second is effectively the entry point to the plugin.
- Develop the plugin code. One of the existing plugins can be used
as reference for popping data out of the circular buffer. Data
structures for parsing such data are defined in network.h file.
The basic layout for the main plugin loop can be grasped in the
print_plugin.c file by looking at content of the "for (;;)" loop.
|