* Instance "exim"
* <Match>
* Regex "S=([1-9][0-9]*)"
+ * ExcludeRegex "U=root.*S="
* DSType "CounterAdd"
* Type "ipt_bytes"
* Instance "total"
struct ctail_config_match_s
{
char *regex;
+ char *excluderegex;
int flags;
char *type;
char *type_instance;
cu_tail_match_t **tail_match_list = NULL;
size_t tail_match_list_num = 0;
-static int ctail_config_add_string (const char *name, char **dest, oconfig_item_t *ci)
-{
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
- {
- WARNING ("tail plugin: `%s' needs exactly one string argument.", name);
- return (-1);
- }
-
- sfree (*dest);
- *dest = strdup (ci->values[0].value.string);
- if (*dest == NULL)
- return (-1);
-
- return (0);
-} /* int ctail_config_add_string */
-
static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
oconfig_item_t *ci)
{
oconfig_item_t *option = ci->children + i;
if (strcasecmp ("Regex", option->key) == 0)
- status = ctail_config_add_string ("Regex", &cm.regex, option);
+ status = cf_util_get_string (option, &cm.regex);
+ else if (strcasecmp ("ExcludeRegex", option->key) == 0)
+ status = cf_util_get_string (option, &cm.excluderegex);
else if (strcasecmp ("DSType", option->key) == 0)
status = ctail_config_add_match_dstype (&cm, option);
else if (strcasecmp ("Type", option->key) == 0)
- status = ctail_config_add_string ("Type", &cm.type, option);
+ status = cf_util_get_string (option, &cm.type);
else if (strcasecmp ("Instance", option->key) == 0)
- status = ctail_config_add_string ("Instance", &cm.type_instance, option);
+ status = cf_util_get_string (option, &cm.type_instance);
else
{
WARNING ("tail plugin: Option `%s' not allowed here.", option->key);
if (status == 0)
{
- status = tail_match_add_match_simple (tm, cm.regex, cm.flags,
- "tail", plugin_instance, cm.type, cm.type_instance);
+ status = tail_match_add_match_simple (tm, cm.regex, cm.excluderegex,
+ cm.flags, "tail", plugin_instance, cm.type, cm.type_instance);
if (status != 0)
{
}
sfree (cm.regex);
+ sfree (cm.excluderegex);
sfree (cm.type);
sfree (cm.type_instance);
cu_tail_match_t *tm;
char *plugin_instance = NULL;
int num_matches = 0;
- int status;
int i;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
if (tm == NULL)
{
ERROR ("tail plugin: tail_match_create (%s) failed.",
- ci->values[0].value.string);
+ ci->values[0].value.string);
return (-1);
}
- status = 0;
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
+ int status = 0;
if (strcasecmp ("Match", option->key) == 0)
{
status = ctail_config_add_match (tm, plugin_instance, option);
if (status == 0)
- num_matches++;
+ num_matches++;
/* Be mild with failed matches.. */
status = 0;
}
else if (strcasecmp ("Instance", option->key) == 0)
- status = ctail_config_add_string ("Instance", &plugin_instance, option);
+ status = cf_util_get_string (option, &plugin_instance);
else
{
WARNING ("tail plugin: Option `%s' not allowed here.", option->key);
break;
} /* for (i = 0; i < ci->children_num; i++) */
+ sfree (plugin_instance);
+
if (num_matches == 0)
{
ERROR ("tail plugin: No (valid) matches found for file `%s'.",
- ci->values[0].value.string);
+ ci->values[0].value.string);
tail_match_destroy (tm);
return (-1);
}
cu_tail_match_t **temp;
temp = (cu_tail_match_t **) realloc (tail_match_list,
- sizeof (cu_tail_match_t *) * (tail_match_list_num + 1));
+ sizeof (cu_tail_match_t *) * (tail_match_list_num + 1));
if (temp == NULL)
{
ERROR ("tail plugin: realloc failed.");