2 * collectd - src/utils_threshold.c
3 * Copyright (C) 2007,2008 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
25 #include "utils_avltree.h"
26 #include "utils_cache.h"
27 #include "utils_threshold.h"
33 * Private data structures
35 #define UT_FLAG_INVERT 0x01
36 #define UT_FLAG_PERSIST 0x02
37 #define UT_FLAG_PERCENTAGE 0x04
41 * Private (static) variables
43 static c_avl_tree_t *threshold_tree = NULL;
44 static pthread_mutex_t threshold_lock = PTHREAD_MUTEX_INITIALIZER;
48 * Threshold management
49 * ====================
50 * The following functions add, delete, search, etc. configured thresholds to
51 * the underlying AVL trees.
53 static threshold_t *threshold_get (const char *hostname,
54 const char *plugin, const char *plugin_instance,
55 const char *type, const char *type_instance)
57 char name[6 * DATA_MAX_NAME_LEN];
58 threshold_t *th = NULL;
60 format_name (name, sizeof (name),
61 (hostname == NULL) ? "" : hostname,
62 (plugin == NULL) ? "" : plugin, plugin_instance,
63 (type == NULL) ? "" : type, type_instance);
64 name[sizeof (name) - 1] = '\0';
66 if (c_avl_get (threshold_tree, name, (void *) &th) == 0)
70 } /* threshold_t *threshold_get */
72 static int ut_threshold_add (const threshold_t *th)
74 char name[6 * DATA_MAX_NAME_LEN];
80 if (format_name (name, sizeof (name), th->host,
81 th->plugin, th->plugin_instance,
82 th->type, th->type_instance) != 0)
84 ERROR ("ut_threshold_add: format_name failed.");
88 name_copy = strdup (name);
89 if (name_copy == NULL)
91 ERROR ("ut_threshold_add: strdup failed.");
95 th_copy = (threshold_t *) malloc (sizeof (threshold_t));
99 ERROR ("ut_threshold_add: malloc failed.");
102 memcpy (th_copy, th, sizeof (threshold_t));
105 DEBUG ("ut_threshold_add: Adding entry `%s'", name);
107 pthread_mutex_lock (&threshold_lock);
109 th_ptr = threshold_get (th->host, th->plugin, th->plugin_instance,
110 th->type, th->type_instance);
112 while ((th_ptr != NULL) && (th_ptr->next != NULL))
113 th_ptr = th_ptr->next;
115 if (th_ptr == NULL) /* no such threshold yet */
117 status = c_avl_insert (threshold_tree, name_copy, th_copy);
119 else /* th_ptr points to the last threshold in the list */
121 th_ptr->next = th_copy;
122 /* name_copy isn't needed */
126 pthread_mutex_unlock (&threshold_lock);
130 ERROR ("ut_threshold_add: c_avl_insert (%s) failed.", name);
136 } /* int ut_threshold_add */
138 * End of the threshold management functions
144 * The following approximately two hundred functions are used to handle the
145 * configuration and fill the threshold list.
147 static int ut_config_type_datasource (threshold_t *th, oconfig_item_t *ci)
149 if ((ci->values_num != 1)
150 || (ci->values[0].type != OCONFIG_TYPE_STRING))
152 WARNING ("threshold values: The `DataSource' option needs exactly one "
157 sstrncpy (th->data_source, ci->values[0].value.string,
158 sizeof (th->data_source));
161 } /* int ut_config_type_datasource */
163 static int ut_config_type_instance (threshold_t *th, oconfig_item_t *ci)
165 if ((ci->values_num != 1)
166 || (ci->values[0].type != OCONFIG_TYPE_STRING))
168 WARNING ("threshold values: The `Instance' option needs exactly one "
173 sstrncpy (th->type_instance, ci->values[0].value.string,
174 sizeof (th->type_instance));
177 } /* int ut_config_type_instance */
179 static int ut_config_type_max (threshold_t *th, oconfig_item_t *ci)
181 if ((ci->values_num != 1)
182 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
184 WARNING ("threshold values: The `%s' option needs exactly one "
185 "number argument.", ci->key);
189 if (strcasecmp (ci->key, "WarningMax") == 0)
190 th->warning_max = ci->values[0].value.number;
192 th->failure_max = ci->values[0].value.number;
195 } /* int ut_config_type_max */
197 static int ut_config_type_min (threshold_t *th, oconfig_item_t *ci)
199 if ((ci->values_num != 1)
200 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
202 WARNING ("threshold values: The `%s' option needs exactly one "
203 "number argument.", ci->key);
207 if (strcasecmp (ci->key, "WarningMin") == 0)
208 th->warning_min = ci->values[0].value.number;
210 th->failure_min = ci->values[0].value.number;
213 } /* int ut_config_type_min */
215 static int ut_config_type_invert (threshold_t *th, oconfig_item_t *ci)
217 if ((ci->values_num != 1)
218 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
220 WARNING ("threshold values: The `Invert' option needs exactly one "
221 "boolean argument.");
225 if (ci->values[0].value.boolean)
226 th->flags |= UT_FLAG_INVERT;
228 th->flags &= ~UT_FLAG_INVERT;
231 } /* int ut_config_type_invert */
233 static int ut_config_type_persist (threshold_t *th, oconfig_item_t *ci)
235 if ((ci->values_num != 1)
236 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
238 WARNING ("threshold values: The `Persist' option needs exactly one "
239 "boolean argument.");
243 if (ci->values[0].value.boolean)
244 th->flags |= UT_FLAG_PERSIST;
246 th->flags &= ~UT_FLAG_PERSIST;
249 } /* int ut_config_type_persist */
251 static int ut_config_type_percentage(threshold_t *th, oconfig_item_t *ci)
253 if ((ci->values_num != 1)
254 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
256 WARNING ("threshold values: The `Percentage' option needs exactly one "
257 "boolean argument.");
261 if (ci->values[0].value.boolean)
262 th->flags |= UT_FLAG_PERCENTAGE;
264 th->flags &= ~UT_FLAG_PERCENTAGE;
267 } /* int ut_config_type_percentage */
269 static int ut_config_type_hits (threshold_t *th, oconfig_item_t *ci)
271 if ((ci->values_num != 1)
272 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
274 WARNING ("threshold values: The `%s' option needs exactly one "
275 "number argument.", ci->key);
279 th->hits = ci->values[0].value.number;
282 } /* int ut_config_type_hits */
284 static int ut_config_type_hysteresis (threshold_t *th, oconfig_item_t *ci)
286 if ((ci->values_num != 1)
287 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
289 WARNING ("threshold values: The `%s' option needs exactly one "
290 "number argument.", ci->key);
294 th->hysteresis = ci->values[0].value.number;
297 } /* int ut_config_type_hysteresis */
299 static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci)
305 if ((ci->values_num != 1)
306 || (ci->values[0].type != OCONFIG_TYPE_STRING))
308 WARNING ("threshold values: The `Type' block needs exactly one string "
313 if (ci->children_num < 1)
315 WARNING ("threshold values: The `Type' block needs at least one option.");
319 memcpy (&th, th_orig, sizeof (th));
320 sstrncpy (th.type, ci->values[0].value.string, sizeof (th.type));
322 th.warning_min = NAN;
323 th.warning_max = NAN;
324 th.failure_min = NAN;
325 th.failure_max = NAN;
329 for (i = 0; i < ci->children_num; i++)
331 oconfig_item_t *option = ci->children + i;
334 if (strcasecmp ("Instance", option->key) == 0)
335 status = ut_config_type_instance (&th, option);
336 else if (strcasecmp ("DataSource", option->key) == 0)
337 status = ut_config_type_datasource (&th, option);
338 else if ((strcasecmp ("WarningMax", option->key) == 0)
339 || (strcasecmp ("FailureMax", option->key) == 0))
340 status = ut_config_type_max (&th, option);
341 else if ((strcasecmp ("WarningMin", option->key) == 0)
342 || (strcasecmp ("FailureMin", option->key) == 0))
343 status = ut_config_type_min (&th, option);
344 else if (strcasecmp ("Invert", option->key) == 0)
345 status = ut_config_type_invert (&th, option);
346 else if (strcasecmp ("Persist", option->key) == 0)
347 status = ut_config_type_persist (&th, option);
348 else if (strcasecmp ("Percentage", option->key) == 0)
349 status = ut_config_type_percentage (&th, option);
350 else if (strcasecmp ("Hits", option->key) == 0)
351 status = ut_config_type_hits (&th, option);
352 else if (strcasecmp ("Hysteresis", option->key) == 0)
353 status = ut_config_type_hysteresis (&th, option);
356 WARNING ("threshold values: Option `%s' not allowed inside a `Type' "
357 "block.", option->key);
367 status = ut_threshold_add (&th);
371 } /* int ut_config_type */
373 static int ut_config_plugin_instance (threshold_t *th, oconfig_item_t *ci)
375 if ((ci->values_num != 1)
376 || (ci->values[0].type != OCONFIG_TYPE_STRING))
378 WARNING ("threshold values: The `Instance' option needs exactly one "
383 sstrncpy (th->plugin_instance, ci->values[0].value.string,
384 sizeof (th->plugin_instance));
387 } /* int ut_config_plugin_instance */
389 static int ut_config_plugin (const threshold_t *th_orig, oconfig_item_t *ci)
395 if ((ci->values_num != 1)
396 || (ci->values[0].type != OCONFIG_TYPE_STRING))
398 WARNING ("threshold values: The `Plugin' block needs exactly one string "
403 if (ci->children_num < 1)
405 WARNING ("threshold values: The `Plugin' block needs at least one nested "
410 memcpy (&th, th_orig, sizeof (th));
411 sstrncpy (th.plugin, ci->values[0].value.string, sizeof (th.plugin));
413 for (i = 0; i < ci->children_num; i++)
415 oconfig_item_t *option = ci->children + i;
418 if (strcasecmp ("Type", option->key) == 0)
419 status = ut_config_type (&th, option);
420 else if (strcasecmp ("Instance", option->key) == 0)
421 status = ut_config_plugin_instance (&th, option);
424 WARNING ("threshold values: Option `%s' not allowed inside a `Plugin' "
425 "block.", option->key);
434 } /* int ut_config_plugin */
436 static int ut_config_host (const threshold_t *th_orig, oconfig_item_t *ci)
442 if ((ci->values_num != 1)
443 || (ci->values[0].type != OCONFIG_TYPE_STRING))
445 WARNING ("threshold values: The `Host' block needs exactly one string "
450 if (ci->children_num < 1)
452 WARNING ("threshold values: The `Host' block needs at least one nested "
457 memcpy (&th, th_orig, sizeof (th));
458 sstrncpy (th.host, ci->values[0].value.string, sizeof (th.host));
460 for (i = 0; i < ci->children_num; i++)
462 oconfig_item_t *option = ci->children + i;
465 if (strcasecmp ("Type", option->key) == 0)
466 status = ut_config_type (&th, option);
467 else if (strcasecmp ("Plugin", option->key) == 0)
468 status = ut_config_plugin (&th, option);
471 WARNING ("threshold values: Option `%s' not allowed inside a `Host' "
472 "block.", option->key);
481 } /* int ut_config_host */
483 int ut_config (const oconfig_item_t *ci)
490 if (ci->values_num != 0)
492 ERROR ("threshold values: The `Threshold' block may not have any "
497 if (threshold_tree == NULL)
499 threshold_tree = c_avl_create ((void *) strcmp);
500 if (threshold_tree == NULL)
502 ERROR ("ut_config: c_avl_create failed.");
507 memset (&th, '\0', sizeof (th));
508 th.warning_min = NAN;
509 th.warning_max = NAN;
510 th.failure_min = NAN;
511 th.failure_max = NAN;
516 for (i = 0; i < ci->children_num; i++)
518 oconfig_item_t *option = ci->children + i;
521 if (strcasecmp ("Type", option->key) == 0)
522 status = ut_config_type (&th, option);
523 else if (strcasecmp ("Plugin", option->key) == 0)
524 status = ut_config_plugin (&th, option);
525 else if (strcasecmp ("Host", option->key) == 0)
526 status = ut_config_host (&th, option);
529 WARNING ("threshold values: Option `%s' not allowed here.", option->key);
538 } /* int um_config */
540 * End of the functions used to configure threshold values.
544 static threshold_t *threshold_search (const value_list_t *vl)
548 if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
549 vl->type, vl->type_instance)) != NULL)
551 else if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
552 vl->type, NULL)) != NULL)
554 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
555 vl->type, vl->type_instance)) != NULL)
557 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
558 vl->type, NULL)) != NULL)
560 else if ((th = threshold_get (vl->host, "", NULL,
561 vl->type, vl->type_instance)) != NULL)
563 else if ((th = threshold_get (vl->host, "", NULL,
564 vl->type, NULL)) != NULL)
566 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
567 vl->type, vl->type_instance)) != NULL)
569 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
570 vl->type, NULL)) != NULL)
572 else if ((th = threshold_get ("", vl->plugin, NULL,
573 vl->type, vl->type_instance)) != NULL)
575 else if ((th = threshold_get ("", vl->plugin, NULL,
576 vl->type, NULL)) != NULL)
578 else if ((th = threshold_get ("", "", NULL,
579 vl->type, vl->type_instance)) != NULL)
581 else if ((th = threshold_get ("", "", NULL,
582 vl->type, NULL)) != NULL)
586 } /* threshold_t *threshold_search */
589 * int ut_report_state
591 * Checks if the `state' differs from the old state and creates a notification
595 static int ut_report_state (const data_set_t *ds,
596 const value_list_t *vl,
597 const threshold_t *th,
598 const gauge_t *values,
610 /* Check if hits matched */
611 if ( (th->hits != 0) )
613 int hits = uc_get_hits(ds,vl);
614 /* The STATE_OKAY always reset hits, or if hits reaise the limit */
615 if ( (state == STATE_OKAY) || (hits > th->hits) )
617 DEBUG("ut_report_state: reset uc_get_hits = 0");
618 uc_set_hits(ds,vl,0); /* reset hit counter and notify */
620 DEBUG("ut_report_state: th->hits = %d, uc_get_hits = %d",th->hits,uc_get_hits(ds,vl));
621 (void) uc_inc_hits(ds,vl,1); /* increase hit counter */
624 } /* end check hits */
626 state_old = uc_get_state (ds, vl);
628 /* If the state didn't change, only report if `persistent' is specified and
629 * the state is not `okay'. */
630 if (state == state_old)
632 if ((th->flags & UT_FLAG_PERSIST) == 0)
634 else if (state == STATE_OKAY)
638 if (state != state_old)
639 uc_set_state (ds, vl, state);
641 NOTIFICATION_INIT_VL (&n, vl, ds);
644 bufsize = sizeof (n.message);
646 if (state == STATE_OKAY)
647 n.severity = NOTIF_OKAY;
648 else if (state == STATE_WARNING)
649 n.severity = NOTIF_WARNING;
651 n.severity = NOTIF_FAILURE;
655 status = ssnprintf (buf, bufsize, "Host %s, plugin %s",
656 vl->host, vl->plugin);
660 if (vl->plugin_instance[0] != '\0')
662 status = ssnprintf (buf, bufsize, " (instance %s)",
663 vl->plugin_instance);
668 status = ssnprintf (buf, bufsize, " type %s", vl->type);
672 if (vl->type_instance[0] != '\0')
674 status = ssnprintf (buf, bufsize, " (instance %s)",
680 plugin_notification_meta_add_string (&n, "DataSource",
681 ds->ds[ds_index].name);
682 plugin_notification_meta_add_double (&n, "CurrentValue", values[ds_index]);
683 plugin_notification_meta_add_double (&n, "WarningMin", th->warning_min);
684 plugin_notification_meta_add_double (&n, "WarningMax", th->warning_max);
685 plugin_notification_meta_add_double (&n, "FailureMin", th->failure_min);
686 plugin_notification_meta_add_double (&n, "FailureMax", th->failure_max);
688 /* Send an okay notification */
689 if (state == STATE_OKAY)
691 status = ssnprintf (buf, bufsize, ": All data sources are within range again.");
700 min = (state == STATE_ERROR) ? th->failure_min : th->warning_min;
701 max = (state == STATE_ERROR) ? th->failure_max : th->warning_max;
703 if (th->flags & UT_FLAG_INVERT)
705 if (!isnan (min) && !isnan (max))
707 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
708 "%f. That is within the %s region of %f%s and %f%s.",
709 ds->ds[ds_index].name, values[ds_index],
710 (state == STATE_ERROR) ? "failure" : "warning",
711 min, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "",
712 max, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
716 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
717 "%f. That is %s the %s threshold of %f%s.",
718 ds->ds[ds_index].name, values[ds_index],
719 isnan (min) ? "below" : "above",
720 (state == STATE_ERROR) ? "failure" : "warning",
721 isnan (min) ? max : min,
722 ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
725 else /* is not inverted */
727 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
728 "%f. That is %s the %s threshold of %f%s.",
729 ds->ds[ds_index].name, values[ds_index],
730 (values[ds_index] < min) ? "below" : "above",
731 (state == STATE_ERROR) ? "failure" : "warning",
732 (values[ds_index] < min) ? min : max,
733 ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
739 plugin_dispatch_notification (&n);
741 plugin_notification_meta_free (n.meta);
743 } /* }}} int ut_report_state */
746 * int ut_check_one_data_source
748 * Checks one data source against the given threshold configuration. If the
749 * `DataSource' option is set in the threshold, and the name does NOT match,
750 * `okay' is returned. If the threshold does match, its failure and warning
751 * min and max values are checked and `failure' or `warning' is returned if
755 static int ut_check_one_data_source (const data_set_t *ds,
756 const value_list_t __attribute__((unused)) *vl,
757 const threshold_t *th,
758 const gauge_t *values,
764 int prev_state = STATE_OKAY;
766 /* check if this threshold applies to this data source */
769 ds_name = ds->ds[ds_index].name;
770 if ((th->data_source[0] != 0)
771 && (strcmp (ds_name, th->data_source) != 0))
775 if ((th->flags & UT_FLAG_INVERT) != 0)
781 /* XXX: This is an experimental code, not optimized, not fast, not reliable,
782 * and probably, do not work as you expect. Enjoy! :D */
783 if ( (th->hysteresis > 0) && ((prev_state = uc_get_state(ds,vl)) != STATE_OKAY) )
788 if ( (!isnan (th->failure_min) && ((th->failure_min + th->hysteresis) < values[ds_index])) ||
789 (!isnan (th->failure_max) && ((th->failure_max - th->hysteresis) > values[ds_index])) )
794 if ( (!isnan (th->warning_min) && ((th->warning_min + th->hysteresis) < values[ds_index])) ||
795 (!isnan (th->warning_max) && ((th->warning_max - th->hysteresis) > values[ds_index])) )
801 else { /* no hysteresis */
802 if ((!isnan (th->failure_min) && (th->failure_min > values[ds_index]))
803 || (!isnan (th->failure_max) && (th->failure_max < values[ds_index])))
806 if ((!isnan (th->warning_min) && (th->warning_min > values[ds_index]))
807 || (!isnan (th->warning_max) && (th->warning_max < values[ds_index])))
812 return (STATE_ERROR);
815 return (STATE_WARNING);
818 } /* }}} int ut_check_one_data_source */
821 * int ut_check_one_threshold
823 * Checks all data sources of a value list against the given threshold, using
824 * the ut_check_one_data_source function above. Returns the worst status,
825 * which is `okay' if nothing has failed.
826 * Returns less than zero if the data set doesn't have any data sources.
828 static int ut_check_one_threshold (const data_set_t *ds,
829 const value_list_t *vl,
830 const threshold_t *th,
831 const gauge_t *values,
837 gauge_t values_copy[ds->ds_num];
839 memcpy (values_copy, values, sizeof (values_copy));
841 if ((th->flags & UT_FLAG_PERCENTAGE) != 0)
848 WARNING ("ut_check_one_threshold: The %s type has only one data "
849 "source, but you have configured to check this as a percentage. "
850 "That doesn't make much sense, because the percentage will always "
851 "be 100%%!", ds->type);
854 /* Prepare `sum' and `num'. */
855 for (i = 0; i < ds->ds_num; i++)
856 if (!isnan (values[i]))
862 if ((num == 0) /* All data sources are undefined. */
863 || (sum == 0.0)) /* Sum is zero, cannot calculate percentage. */
865 for (i = 0; i < ds->ds_num; i++)
866 values_copy[i] = NAN;
868 else /* We can actually calculate the percentage. */
870 for (i = 0; i < ds->ds_num; i++)
871 values_copy[i] = 100.0 * values[i] / sum;
873 } /* if (UT_FLAG_PERCENTAGE) */
875 for (i = 0; i < ds->ds_num; i++)
879 status = ut_check_one_data_source (ds, vl, th, values_copy, i);
885 } /* for (ds->ds_num) */
887 if (ret_ds_index != NULL)
888 *ret_ds_index = ds_index;
891 } /* }}} int ut_check_one_threshold */
894 * int ut_check_threshold (PUBLIC)
896 * Gets a list of matching thresholds and searches for the worst status by one
897 * of the thresholds. Then reports that status using the ut_report_state
899 * Returns zero on success and if no threshold has been configured. Returns
900 * less than zero on failure.
902 int ut_check_threshold (const data_set_t *ds, const value_list_t *vl)
908 int worst_state = -1;
909 threshold_t *worst_th = NULL;
910 int worst_ds_index = -1;
912 if (threshold_tree == NULL)
915 /* Is this lock really necessary? So far, thresholds are only inserted at
917 pthread_mutex_lock (&threshold_lock);
918 th = threshold_search (vl);
919 pthread_mutex_unlock (&threshold_lock);
923 DEBUG ("ut_check_threshold: Found matching threshold(s)");
925 values = uc_get_rate (ds, vl);
933 status = ut_check_one_threshold (ds, vl, th, values, &ds_index);
936 ERROR ("ut_check_threshold: ut_check_one_threshold failed.");
941 if (worst_state < status)
943 worst_state = status;
945 worst_ds_index = ds_index;
951 status = ut_report_state (ds, vl, worst_th, values,
952 worst_ds_index, worst_state);
955 ERROR ("ut_check_threshold: ut_report_state failed.");
963 } /* }}} int ut_check_threshold */
966 * int ut_check_interesting (PUBLIC)
968 * Given an identification returns
969 * 0: No threshold is defined.
970 * 1: A threshold has been found. The flag `persist' is off.
971 * 2: A threshold has been found. The flag `persist' is on.
972 * (That is, it is expected that many notifications are sent until the
973 * problem disappears.)
975 int ut_check_interesting (const char *name)
977 char *name_copy = NULL;
980 char *plugin_instance = NULL;
982 char *type_instance = NULL;
988 /* If there is no tree nothing is interesting. */
989 if (threshold_tree == NULL)
992 name_copy = strdup (name);
993 if (name_copy == NULL)
995 ERROR ("ut_check_interesting: strdup failed.");
999 status = parse_identifier (name_copy, &host,
1000 &plugin, &plugin_instance, &type, &type_instance);
1003 ERROR ("ut_check_interesting: parse_identifier failed.");
1008 memset (&ds, '\0', sizeof (ds));
1009 memset (&vl, '\0', sizeof (vl));
1011 sstrncpy (vl.host, host, sizeof (vl.host));
1012 sstrncpy (vl.plugin, plugin, sizeof (vl.plugin));
1013 if (plugin_instance != NULL)
1014 sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
1015 sstrncpy (ds.type, type, sizeof (ds.type));
1016 sstrncpy (vl.type, type, sizeof (vl.type));
1017 if (type_instance != NULL)
1018 sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
1021 host = plugin = plugin_instance = type = type_instance = NULL;
1023 th = threshold_search (&vl);
1026 if ((th->flags & UT_FLAG_PERSIST) == 0)
1029 } /* }}} int ut_check_interesting */
1031 int ut_search_threshold (const value_list_t *vl, /* {{{ */
1032 threshold_t *ret_threshold)
1039 t = threshold_search (vl);
1043 memcpy (ret_threshold, t, sizeof (*ret_threshold));
1044 ret_threshold->next = NULL;
1047 } /* }}} int ut_search_threshold */
1049 /* vim: set sw=2 ts=8 sts=2 tw=78 et fdm=marker : */