[collectd] Generalized ignorelist functionality
Luboš Staněk
lubek at users.sourceforge.net
Wed Nov 22 15:54:09 CET 2006
Hi Florian,
> right, you need to escape special characters if you literally mean the
> characters. But all the common characters (A-Z, a-z, 0-9, slash, hyphen,
> underscore, ...) don't have any special meaning. I don't expect this to
> be a problem, if it's documented in the manpage.
>
> Another thing might be confusing: If you want a regex to match the
> entire string, you need to say so. People might write `hda' and expect
> to only get the string that is exactly `hda', while in fact they will
> also get `hda1' or `catchdanger'.
>
> Another possibility just crossed my mind: We could explicitely mark
> literal strings, e. g. by enclosing them in double-quotes. This would
> mean, that the following two lines mean the same thing:
> "foobar"
> ^foobar$
>
To summarize:
- "string" - means full match string -> will be converted to ^string$
- any other string:
- string - means partial match -> no conversion, append as regex
- ^string$ - means full match regex -> no conversion, append as regex
The user is responsible for providing prefixed characters (if any)
inside any variant.
------ snip -----------
/*
* match entire "string", make it a ^regex$
*/
if ((entry_len > 2) && (entry[0] == '"') && (entry[strlen(entry) - 1] ==
'"'))
{
/* We need to copy `entry' since it's const */
entry_copy = smalloc (entry_len);
memset (entry_copy, '\0', entry_len);
strcpy (entry_copy, '^');
strncat (entry_copy, entry + 1, entry_len - 2);
strcat (entry_copy, '$');
DBG("I'm about to add full match regex entry: %s", entry_copy);
ret = ignorelist_append_regex(il, entry_copy);
sfree (entry_copy);
}
else
/*
* otherwise make it simply a regex (partial/full match)
*/
{
DBG("I'm about to add partial match regex entry: %s", entry);
ret = ignorelist_append_regex(il, entry);
}
------ snip -----------
The last problem is that the user does not have any tool to check or
test his own expressions.
The log contains only error messages in cases where the regex cannot be
compiled.
He has the only possibility to check whether the appropriate .rrd exists
and is regularly updated every STEP.
Best regards,
Lubos
More information about the collectd
mailing list