/*
* Private (static) variables
* {{{ */
-static avl_tree_t *threshold_tree = NULL;
+static c_avl_tree_t *threshold_tree = NULL;
static pthread_mutex_t threshold_lock = PTHREAD_MUTEX_INITIALIZER;
/* }}} */
DEBUG ("ut_threshold_add: Adding entry `%s'", name);
pthread_mutex_lock (&threshold_lock);
- status = avl_insert (threshold_tree, name_copy, th_copy);
+ status = c_avl_insert (threshold_tree, name_copy, th_copy);
pthread_mutex_unlock (&threshold_lock);
if (status != 0)
{
- ERROR ("ut_threshold_add: avl_insert (%s) failed.", name);
+ ERROR ("ut_threshold_add: c_avl_insert (%s) failed.", name);
sfree (name_copy);
sfree (th_copy);
}
return (0);
} /* int ut_config_type_invert */
+static int ut_config_type_persist (threshold_t *th, oconfig_item_t *ci)
+{
+ if ((ci->values_num != 1)
+ || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
+ {
+ WARNING ("threshold values: The `Persist' option needs exactly one "
+ "boolean argument.");
+ return (-1);
+ }
+
+ if (ci->values[0].value.boolean)
+ th->flags |= UT_FLAG_PERSIST;
+ else
+ th->flags &= ~UT_FLAG_PERSIST;
+
+ return (0);
+} /* int ut_config_type_persist */
+
static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci)
{
int i;
status = ut_config_type_min (&th, option);
else if (strcasecmp ("Invert", option->key) == 0)
status = ut_config_type_invert (&th, option);
+ else if (strcasecmp ("Persist", option->key) == 0)
+ status = ut_config_type_persist (&th, option);
else
{
WARNING ("threshold values: Option `%s' not allowed inside a `Type' "
if (threshold_tree == NULL)
{
- threshold_tree = avl_create ((void *) strcmp);
+ threshold_tree = c_avl_create ((void *) strcmp);
if (threshold_tree == NULL)
{
- ERROR ("ut_config: avl_create failed.");
+ ERROR ("ut_config: c_avl_create failed.");
return (-1);
}
}
(type == NULL) ? "" : type, type_instance);
name[sizeof (name) - 1] = '\0';
- if (avl_get (threshold_tree, name, (void *) &th) == 0)
+ if (c_avl_get (threshold_tree, name, (void *) &th) == 0)
return (th);
else
return (NULL);
host = plugin = plugin_instance = type = type_instance = NULL;
th = threshold_search (&ds, &vl);
- if (th != NULL)
- return (1);
- else
+ if (th == NULL)
return (0);
+ if ((th->flags & UT_FLAG_PERSIST) == 0)
+ return (1);
+ return (2);
} /* int ut_check_interesting */
/* vim: set sw=2 ts=8 sts=2 tw=78 fdm=marker : */