[collectd] Generalized ignorelist functionality

Luboš Staněk lubek at users.sourceforge.net
Mon Nov 13 17:52:35 CET 2006


Hi Florian,
you almost wrote it.

> 
> in general, yes. With minor changes though:
> 
> <utils_ignorelist.h>
>  struct ignorelist_s;
>  typedef struct ignorelist_s ignorelist_t;
> 
>  ignorelist_t *ignorelist_create (int inverse);
>  void ignorelist_destroy (ignorelist_t *);
> 
>  int ignorelist_add (ignorelist_t *, const char *);
>  int ignorelist_match (ignorelist_t *, const char *);
> </utils_ignorelist.h>
> 
> <utils_ignorelist.c>
>  struct ignorelist_s
>  {
>   char *match;
>   /* Whatever else is needed */
>   ignorelist_t *next;
>  };
> </utils_ignorelist.c>
> 
> I am a big fan of `opaque data types' for this sort of thing: Since
> plugins shouldn't care how the ignorelist works internally, they should
> not even _know_. This simply prevents wrong usage (i. e. usage of
> things, that are not considered part of the public interface). The folks
> in Redmond have demonstrated impressingly why it is a good idea to do it
> like this ;) If we decide to use a binary tree (b-tree, red-black-tree,
> whatever) in the future we don't need to care about plugins at all.
> 
> Regards,
> -octo


I took your remarks and draft and created the "ignore" feature, with
minor changes though. It handles all required tasks and adds POSIX
regular expressions.
The code is attached to the message.

Remarks:
- the string comparison is case sensitive for both a string and a regex


Warning!
This is really ALPHA software that needs another pair of eyes at least
(a half pair is also possible).

The archive contains sources and diffs to incorporate the feature into
the test tree (current git master). I implemented it in the sensors
plugin because I am familiar with it.
The autoconf part is a quick hack to have the possibility to build the
code with and without regex.


And now something for the entertainment.
These graphs are of no value. You can take it as a computer art. :)
The stats procedure was not objective.

I did a hack in the plugin.c source to get timing stats for the
plugin_read() routine call for both unmodified and modified "sensors"
plugin.
Then I tested all variants:
- old
- new, string compare, regex was not compiled in
- new with regex
for an hour.
The "Sensor" config commands was for string versions:
	Sensor it8712-isa-0290/temperature-temp3
	Sensor it8712-isa-0290/fanspeed-fan3
	Sensor it8712-isa-0290/voltage-in3
and for the regex version:
	Sensor |.*\/temperature-.*3|
	Sensor |.*\/fanspeed-.*3|
	Sensor |.*\/voltage-.*3|

The load of the system was about 0.55 during tests.

The primary reason for such test was to have some information about
regex code efficiency.
The result is: It can be used both as a replacement and a combination
with ordinary string compare.

Enjoy my first computer art,
Lubos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: collectd-ignore.tar.bz2
Type: application/x-bzip
Size: 6539 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061113/4d1e581d/collectd-ignore.tar-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config_list-noregex.png
Type: image/png
Size: 25622 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061113/4d1e581d/config_list-noregex-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config_list-regex.png
Type: image/png
Size: 23883 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061113/4d1e581d/config_list-regex-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no-config_list-old.png
Type: image/png
Size: 29178 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061113/4d1e581d/no-config_list-old-0001.png


More information about the collectd mailing list