X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_riemann_threshold.c;h=5c8559eb7b157414cd86df73a07ae25ab4e6927b;hb=ac077f078300f47d5a6b75aaeeb0999799309283;hp=ff96843b7b62083c39d10143577bba671c4c460e;hpb=cf65f7ec5e19a99dd972a78e6c798fd478710663;p=collectd.git diff --git a/src/write_riemann_threshold.c b/src/write_riemann_threshold.c index ff96843b..5c8559eb 100644 --- a/src/write_riemann_threshold.c +++ b/src/write_riemann_threshold.c @@ -39,86 +39,9 @@ /* * Threshold management * ==================== - * The following functions add, delete, search, etc. configured thresholds to + * The following functions add, delete, etc. configured thresholds to * the underlying AVL trees. */ -/* - * threshold_t *threshold_get - * - * Retrieve one specific threshold configuration. For looking up a threshold - * matching a value_list_t, see "threshold_search" below. Returns NULL if the - * specified threshold doesn't exist. - */ -static threshold_t *threshold_get (const char *hostname, - const char *plugin, const char *plugin_instance, - const char *type, const char *type_instance) -{ /* {{{ */ - char name[6 * DATA_MAX_NAME_LEN]; - threshold_t *th = NULL; - - format_name (name, sizeof (name), - (hostname == NULL) ? "" : hostname, - (plugin == NULL) ? "" : plugin, plugin_instance, - (type == NULL) ? "" : type, type_instance); - name[sizeof (name) - 1] = '\0'; - - if (c_avl_get (threshold_tree, name, (void *) &th) == 0) - return (th); - else - return (NULL); -} /* }}} threshold_t *threshold_get */ - -/* - * threshold_t *threshold_search - * - * Searches for a threshold configuration using all the possible variations of - * "Host", "Plugin" and "Type" blocks. Returns NULL if no threshold could be - * found. - * XXX: This is likely the least efficient function in collectd. - */ -static threshold_t *threshold_search (const value_list_t *vl) -{ /* {{{ */ - threshold_t *th; - - if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance, - vl->type, NULL)) != NULL) - return (th); - else if ((th = threshold_get (vl->host, vl->plugin, NULL, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get (vl->host, vl->plugin, NULL, - vl->type, NULL)) != NULL) - return (th); - else if ((th = threshold_get (vl->host, "", NULL, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get (vl->host, "", NULL, - vl->type, NULL)) != NULL) - return (th); - else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance, - vl->type, NULL)) != NULL) - return (th); - else if ((th = threshold_get ("", vl->plugin, NULL, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get ("", vl->plugin, NULL, - vl->type, NULL)) != NULL) - return (th); - else if ((th = threshold_get ("", "", NULL, - vl->type, vl->type_instance)) != NULL) - return (th); - else if ((th = threshold_get ("", "", NULL, - vl->type, NULL)) != NULL) - return (th); - - return (NULL); -} /* }}} threshold_t *threshold_search */ /* * int ut_check_one_data_source @@ -210,7 +133,7 @@ static int ut_check_one_threshold (const data_set_t *ds, int *statuses) { /* {{{ */ int ret = -1; - int i; + size_t i; int status; gauge_t values_copy[ds->ds_num]; @@ -279,7 +202,9 @@ int write_riemann_threshold_check (const data_set_t *ds, const value_list_t *vl, gauge_t *values; int status; + assert (vl->values_len > 0); memset(statuses, 0, vl->values_len * sizeof(*statuses)); + if (threshold_tree == NULL) return 0;