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"
32 * Private data structures
34 #define UT_FLAG_INVERT 0x01
35 #define UT_FLAG_PERSIST 0x02
36 #define UT_FLAG_PERCENTAGE 0x04
38 typedef struct threshold_s
40 char host[DATA_MAX_NAME_LEN];
41 char plugin[DATA_MAX_NAME_LEN];
42 char plugin_instance[DATA_MAX_NAME_LEN];
43 char type[DATA_MAX_NAME_LEN];
44 char type_instance[DATA_MAX_NAME_LEN];
45 char data_source[DATA_MAX_NAME_LEN];
53 struct threshold_s *next;
58 * Private (static) variables
60 static c_avl_tree_t *threshold_tree = NULL;
61 static pthread_mutex_t threshold_lock = PTHREAD_MUTEX_INITIALIZER;
65 * Threshold management
66 * ====================
67 * The following functions add, delete, search, etc. configured thresholds to
68 * the underlying AVL trees.
70 static threshold_t *threshold_get (const char *hostname,
71 const char *plugin, const char *plugin_instance,
72 const char *type, const char *type_instance)
74 char name[6 * DATA_MAX_NAME_LEN];
75 threshold_t *th = NULL;
77 format_name (name, sizeof (name),
78 (hostname == NULL) ? "" : hostname,
79 (plugin == NULL) ? "" : plugin, plugin_instance,
80 (type == NULL) ? "" : type, type_instance);
81 name[sizeof (name) - 1] = '\0';
83 if (c_avl_get (threshold_tree, name, (void *) &th) == 0)
87 } /* threshold_t *threshold_get */
89 static int ut_threshold_add (const threshold_t *th)
91 char name[6 * DATA_MAX_NAME_LEN];
97 if (format_name (name, sizeof (name), th->host,
98 th->plugin, th->plugin_instance,
99 th->type, th->type_instance) != 0)
101 ERROR ("ut_threshold_add: format_name failed.");
105 name_copy = strdup (name);
106 if (name_copy == NULL)
108 ERROR ("ut_threshold_add: strdup failed.");
112 th_copy = (threshold_t *) malloc (sizeof (threshold_t));
116 ERROR ("ut_threshold_add: malloc failed.");
119 memcpy (th_copy, th, sizeof (threshold_t));
122 DEBUG ("ut_threshold_add: Adding entry `%s'", name);
124 pthread_mutex_lock (&threshold_lock);
126 th_ptr = threshold_get (th->host, th->plugin, th->plugin_instance,
127 th->type, th->type_instance);
129 while ((th_ptr != NULL) && (th_ptr->next != NULL))
130 th_ptr = th_ptr->next;
132 if (th_ptr == NULL) /* no such threshold yet */
134 status = c_avl_insert (threshold_tree, name_copy, th_copy);
136 else /* th_ptr points to the last threshold in the list */
138 th_ptr->next = th_copy;
139 /* name_copy isn't needed */
143 pthread_mutex_unlock (&threshold_lock);
147 ERROR ("ut_threshold_add: c_avl_insert (%s) failed.", name);
153 } /* int ut_threshold_add */
155 * End of the threshold management functions
161 * The following approximately two hundred functions are used to handle the
162 * configuration and fill the threshold list.
164 static int ut_config_type_datasource (threshold_t *th, oconfig_item_t *ci)
166 if ((ci->values_num != 1)
167 || (ci->values[0].type != OCONFIG_TYPE_STRING))
169 WARNING ("threshold values: The `DataSource' option needs exactly one "
174 sstrncpy (th->data_source, ci->values[0].value.string,
175 sizeof (th->data_source));
178 } /* int ut_config_type_datasource */
180 static int ut_config_type_instance (threshold_t *th, oconfig_item_t *ci)
182 if ((ci->values_num != 1)
183 || (ci->values[0].type != OCONFIG_TYPE_STRING))
185 WARNING ("threshold values: The `Instance' option needs exactly one "
190 sstrncpy (th->type_instance, ci->values[0].value.string,
191 sizeof (th->type_instance));
194 } /* int ut_config_type_instance */
196 static int ut_config_type_max (threshold_t *th, oconfig_item_t *ci)
198 if ((ci->values_num != 1)
199 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
201 WARNING ("threshold values: The `%s' option needs exactly one "
202 "number argument.", ci->key);
206 if (strcasecmp (ci->key, "WarningMax") == 0)
207 th->warning_max = ci->values[0].value.number;
209 th->failure_max = ci->values[0].value.number;
212 } /* int ut_config_type_max */
214 static int ut_config_type_min (threshold_t *th, oconfig_item_t *ci)
216 if ((ci->values_num != 1)
217 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
219 WARNING ("threshold values: The `%s' option needs exactly one "
220 "number argument.", ci->key);
224 if (strcasecmp (ci->key, "WarningMin") == 0)
225 th->warning_min = ci->values[0].value.number;
227 th->failure_min = ci->values[0].value.number;
230 } /* int ut_config_type_min */
232 static int ut_config_type_invert (threshold_t *th, oconfig_item_t *ci)
234 if ((ci->values_num != 1)
235 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
237 WARNING ("threshold values: The `Invert' option needs exactly one "
238 "boolean argument.");
242 if (ci->values[0].value.boolean)
243 th->flags |= UT_FLAG_INVERT;
245 th->flags &= ~UT_FLAG_INVERT;
248 } /* int ut_config_type_invert */
250 static int ut_config_type_persist (threshold_t *th, oconfig_item_t *ci)
252 if ((ci->values_num != 1)
253 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
255 WARNING ("threshold values: The `Persist' option needs exactly one "
256 "boolean argument.");
260 if (ci->values[0].value.boolean)
261 th->flags |= UT_FLAG_PERSIST;
263 th->flags &= ~UT_FLAG_PERSIST;
266 } /* int ut_config_type_persist */
268 static int ut_config_type_percentage(threshold_t *th, oconfig_item_t *ci)
270 if ((ci->values_num != 1)
271 || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
273 WARNING ("threshold values: The `Percentage' option needs exactly one "
274 "boolean argument.");
278 if (ci->values[0].value.boolean)
279 th->flags |= UT_FLAG_PERCENTAGE;
281 th->flags &= ~UT_FLAG_PERCENTAGE;
284 } /* int ut_config_type_percentage */
286 static int ut_config_type_hits (threshold_t *th, oconfig_item_t *ci)
288 if ((ci->values_num != 1)
289 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
291 WARNING ("threshold values: The `%s' option needs exactly one "
292 "number argument.", ci->key);
296 th->hits = ci->values[0].value.number;
299 } /* int ut_config_type_hits */
301 static int ut_config_type_hysteresis (threshold_t *th, oconfig_item_t *ci)
303 if ((ci->values_num != 1)
304 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
306 WARNING ("threshold values: The `%s' option needs exactly one "
307 "number argument.", ci->key);
311 th->hysteresis = ci->values[0].value.number;
314 } /* int ut_config_type_hysteresis */
316 static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci)
322 if ((ci->values_num != 1)
323 || (ci->values[0].type != OCONFIG_TYPE_STRING))
325 WARNING ("threshold values: The `Type' block needs exactly one string "
330 if (ci->children_num < 1)
332 WARNING ("threshold values: The `Type' block needs at least one option.");
336 memcpy (&th, th_orig, sizeof (th));
337 sstrncpy (th.type, ci->values[0].value.string, sizeof (th.type));
339 th.warning_min = NAN;
340 th.warning_max = NAN;
341 th.failure_min = NAN;
342 th.failure_max = NAN;
346 for (i = 0; i < ci->children_num; i++)
348 oconfig_item_t *option = ci->children + i;
351 if (strcasecmp ("Instance", option->key) == 0)
352 status = ut_config_type_instance (&th, option);
353 else if (strcasecmp ("DataSource", option->key) == 0)
354 status = ut_config_type_datasource (&th, option);
355 else if ((strcasecmp ("WarningMax", option->key) == 0)
356 || (strcasecmp ("FailureMax", option->key) == 0))
357 status = ut_config_type_max (&th, option);
358 else if ((strcasecmp ("WarningMin", option->key) == 0)
359 || (strcasecmp ("FailureMin", option->key) == 0))
360 status = ut_config_type_min (&th, option);
361 else if (strcasecmp ("Invert", option->key) == 0)
362 status = ut_config_type_invert (&th, option);
363 else if (strcasecmp ("Persist", option->key) == 0)
364 status = ut_config_type_persist (&th, option);
365 else if (strcasecmp ("Percentage", option->key) == 0)
366 status = ut_config_type_percentage (&th, option);
367 else if (strcasecmp ("Hits", option->key) == 0)
368 status = ut_config_type_hits (&th, option);
369 else if (strcasecmp ("Hysteresis", option->key) == 0)
370 status = ut_config_type_hysteresis (&th, option);
373 WARNING ("threshold values: Option `%s' not allowed inside a `Type' "
374 "block.", option->key);
384 status = ut_threshold_add (&th);
388 } /* int ut_config_type */
390 static int ut_config_plugin_instance (threshold_t *th, oconfig_item_t *ci)
392 if ((ci->values_num != 1)
393 || (ci->values[0].type != OCONFIG_TYPE_STRING))
395 WARNING ("threshold values: The `Instance' option needs exactly one "
400 sstrncpy (th->plugin_instance, ci->values[0].value.string,
401 sizeof (th->plugin_instance));
404 } /* int ut_config_plugin_instance */
406 static int ut_config_plugin (const threshold_t *th_orig, oconfig_item_t *ci)
412 if ((ci->values_num != 1)
413 || (ci->values[0].type != OCONFIG_TYPE_STRING))
415 WARNING ("threshold values: The `Plugin' block needs exactly one string "
420 if (ci->children_num < 1)
422 WARNING ("threshold values: The `Plugin' block needs at least one nested "
427 memcpy (&th, th_orig, sizeof (th));
428 sstrncpy (th.plugin, ci->values[0].value.string, sizeof (th.plugin));
430 for (i = 0; i < ci->children_num; i++)
432 oconfig_item_t *option = ci->children + i;
435 if (strcasecmp ("Type", option->key) == 0)
436 status = ut_config_type (&th, option);
437 else if (strcasecmp ("Instance", option->key) == 0)
438 status = ut_config_plugin_instance (&th, option);
441 WARNING ("threshold values: Option `%s' not allowed inside a `Plugin' "
442 "block.", option->key);
451 } /* int ut_config_plugin */
453 static int ut_config_host (const threshold_t *th_orig, oconfig_item_t *ci)
459 if ((ci->values_num != 1)
460 || (ci->values[0].type != OCONFIG_TYPE_STRING))
462 WARNING ("threshold values: The `Host' block needs exactly one string "
467 if (ci->children_num < 1)
469 WARNING ("threshold values: The `Host' block needs at least one nested "
474 memcpy (&th, th_orig, sizeof (th));
475 sstrncpy (th.host, ci->values[0].value.string, sizeof (th.host));
477 for (i = 0; i < ci->children_num; i++)
479 oconfig_item_t *option = ci->children + i;
482 if (strcasecmp ("Type", option->key) == 0)
483 status = ut_config_type (&th, option);
484 else if (strcasecmp ("Plugin", option->key) == 0)
485 status = ut_config_plugin (&th, option);
488 WARNING ("threshold values: Option `%s' not allowed inside a `Host' "
489 "block.", option->key);
498 } /* int ut_config_host */
500 int ut_config (const oconfig_item_t *ci)
507 if (ci->values_num != 0)
509 ERROR ("threshold values: The `Threshold' block may not have any "
514 if (threshold_tree == NULL)
516 threshold_tree = c_avl_create ((void *) strcmp);
517 if (threshold_tree == NULL)
519 ERROR ("ut_config: c_avl_create failed.");
524 memset (&th, '\0', sizeof (th));
525 th.warning_min = NAN;
526 th.warning_max = NAN;
527 th.failure_min = NAN;
528 th.failure_max = NAN;
533 for (i = 0; i < ci->children_num; i++)
535 oconfig_item_t *option = ci->children + i;
538 if (strcasecmp ("Type", option->key) == 0)
539 status = ut_config_type (&th, option);
540 else if (strcasecmp ("Plugin", option->key) == 0)
541 status = ut_config_plugin (&th, option);
542 else if (strcasecmp ("Host", option->key) == 0)
543 status = ut_config_host (&th, option);
546 WARNING ("threshold values: Option `%s' not allowed here.", option->key);
555 } /* int um_config */
557 * End of the functions used to configure threshold values.
561 static threshold_t *threshold_search (const value_list_t *vl)
565 if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
566 vl->type, vl->type_instance)) != NULL)
568 else if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
569 vl->type, NULL)) != NULL)
571 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
572 vl->type, vl->type_instance)) != NULL)
574 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
575 vl->type, NULL)) != NULL)
577 else if ((th = threshold_get (vl->host, "", NULL,
578 vl->type, vl->type_instance)) != NULL)
580 else if ((th = threshold_get (vl->host, "", NULL,
581 vl->type, NULL)) != NULL)
583 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
584 vl->type, vl->type_instance)) != NULL)
586 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
587 vl->type, NULL)) != NULL)
589 else if ((th = threshold_get ("", vl->plugin, NULL,
590 vl->type, vl->type_instance)) != NULL)
592 else if ((th = threshold_get ("", vl->plugin, NULL,
593 vl->type, NULL)) != NULL)
595 else if ((th = threshold_get ("", "", NULL,
596 vl->type, vl->type_instance)) != NULL)
598 else if ((th = threshold_get ("", "", NULL,
599 vl->type, NULL)) != NULL)
603 } /* threshold_t *threshold_search */
606 * int ut_report_state
608 * Checks if the `state' differs from the old state and creates a notification
612 static int ut_report_state (const data_set_t *ds,
613 const value_list_t *vl,
614 const threshold_t *th,
615 const gauge_t *values,
627 /* Check if hits matched */
628 if ( (th->hits != 0) )
630 int hits = uc_get_hits(ds,vl);
631 /* The STATE_OKAY always reset hits, or if hits reaise the limit */
632 if ( (state == STATE_OKAY) || (hits > th->hits) )
634 DEBUG("ut_report_state: reset uc_get_hits = 0");
635 uc_set_hits(ds,vl,0); /* reset hit counter and notify */
637 DEBUG("ut_report_state: th->hits = %d, uc_get_hits = %d",th->hits,uc_get_hits(ds,vl));
638 (void) uc_inc_hits(ds,vl,1); /* increase hit counter */
641 } /* end check hits */
643 state_old = uc_get_state (ds, vl);
645 /* If the state didn't change, only report if `persistent' is specified and
646 * the state is not `okay'. */
647 if (state == state_old)
649 if ((th->flags & UT_FLAG_PERSIST) == 0)
651 else if (state == STATE_OKAY)
655 if (state != state_old)
656 uc_set_state (ds, vl, state);
658 NOTIFICATION_INIT_VL (&n, vl, ds);
661 bufsize = sizeof (n.message);
663 if (state == STATE_OKAY)
664 n.severity = NOTIF_OKAY;
665 else if (state == STATE_WARNING)
666 n.severity = NOTIF_WARNING;
668 n.severity = NOTIF_FAILURE;
672 status = ssnprintf (buf, bufsize, "Host %s, plugin %s",
673 vl->host, vl->plugin);
677 if (vl->plugin_instance[0] != '\0')
679 status = ssnprintf (buf, bufsize, " (instance %s)",
680 vl->plugin_instance);
685 status = ssnprintf (buf, bufsize, " type %s", vl->type);
689 if (vl->type_instance[0] != '\0')
691 status = ssnprintf (buf, bufsize, " (instance %s)",
697 plugin_notification_meta_add_string (&n, "DataSource",
698 ds->ds[ds_index].name);
699 plugin_notification_meta_add_double (&n, "CurrentValue", values[ds_index]);
700 plugin_notification_meta_add_double (&n, "WarningMin", th->warning_min);
701 plugin_notification_meta_add_double (&n, "WarningMax", th->warning_max);
702 plugin_notification_meta_add_double (&n, "FailureMin", th->failure_min);
703 plugin_notification_meta_add_double (&n, "FailureMax", th->failure_max);
705 /* Send an okay notification */
706 if (state == STATE_OKAY)
708 status = ssnprintf (buf, bufsize, ": All data sources are within range again.");
717 min = (state == STATE_ERROR) ? th->failure_min : th->warning_min;
718 max = (state == STATE_ERROR) ? th->failure_max : th->warning_max;
720 if (th->flags & UT_FLAG_INVERT)
722 if (!isnan (min) && !isnan (max))
724 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
725 "%f. That is within the %s region of %f%s and %f%s.",
726 ds->ds[ds_index].name, values[ds_index],
727 (state == STATE_ERROR) ? "failure" : "warning",
728 min, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "",
729 max, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
733 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
734 "%f. That is %s the %s threshold of %f%s.",
735 ds->ds[ds_index].name, values[ds_index],
736 isnan (min) ? "below" : "above",
737 (state == STATE_ERROR) ? "failure" : "warning",
738 isnan (min) ? max : min,
739 ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
742 else /* is not inverted */
744 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
745 "%f. That is %s the %s threshold of %f%s.",
746 ds->ds[ds_index].name, values[ds_index],
747 (values[ds_index] < min) ? "below" : "above",
748 (state == STATE_ERROR) ? "failure" : "warning",
749 (values[ds_index] < min) ? min : max,
750 ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
756 plugin_dispatch_notification (&n);
758 plugin_notification_meta_free (n.meta);
760 } /* }}} int ut_report_state */
763 * int ut_check_one_data_source
765 * Checks one data source against the given threshold configuration. If the
766 * `DataSource' option is set in the threshold, and the name does NOT match,
767 * `okay' is returned. If the threshold does match, its failure and warning
768 * min and max values are checked and `failure' or `warning' is returned if
772 static int ut_check_one_data_source (const data_set_t *ds,
773 const value_list_t __attribute__((unused)) *vl,
774 const threshold_t *th,
775 const gauge_t *values,
781 int prev_state = STATE_OKAY;
783 /* check if this threshold applies to this data source */
786 ds_name = ds->ds[ds_index].name;
787 if ((th->data_source[0] != 0)
788 && (strcmp (ds_name, th->data_source) != 0))
792 if ((th->flags & UT_FLAG_INVERT) != 0)
798 /* XXX: This is an experimental code, not optimized, not fast, not reliable,
799 * and probably, do not work as you expect. Enjoy! :D */
800 if ( (th->hysteresis > 0) && ((prev_state = uc_get_state(ds,vl)) != STATE_OKAY) )
805 if ( (!isnan (th->failure_min) && ((th->failure_min + th->hysteresis) < values[ds_index])) ||
806 (!isnan (th->failure_max) && ((th->failure_max - th->hysteresis) > values[ds_index])) )
811 if ( (!isnan (th->warning_min) && ((th->warning_min + th->hysteresis) < values[ds_index])) ||
812 (!isnan (th->warning_max) && ((th->warning_max - th->hysteresis) > values[ds_index])) )
818 else { /* no hysteresis */
819 if ((!isnan (th->failure_min) && (th->failure_min > values[ds_index]))
820 || (!isnan (th->failure_max) && (th->failure_max < values[ds_index])))
823 if ((!isnan (th->warning_min) && (th->warning_min > values[ds_index]))
824 || (!isnan (th->warning_max) && (th->warning_max < values[ds_index])))
829 return (STATE_ERROR);
832 return (STATE_WARNING);
835 } /* }}} int ut_check_one_data_source */
838 * int ut_check_one_threshold
840 * Checks all data sources of a value list against the given threshold, using
841 * the ut_check_one_data_source function above. Returns the worst status,
842 * which is `okay' if nothing has failed.
843 * Returns less than zero if the data set doesn't have any data sources.
845 static int ut_check_one_threshold (const data_set_t *ds,
846 const value_list_t *vl,
847 const threshold_t *th,
848 const gauge_t *values,
854 gauge_t values_copy[ds->ds_num];
856 memcpy (values_copy, values, sizeof (values_copy));
858 if ((th->flags & UT_FLAG_PERCENTAGE) != 0)
865 WARNING ("ut_check_one_threshold: The %s type has only one data "
866 "source, but you have configured to check this as a percentage. "
867 "That doesn't make much sense, because the percentage will always "
868 "be 100%%!", ds->type);
871 /* Prepare `sum' and `num'. */
872 for (i = 0; i < ds->ds_num; i++)
873 if (!isnan (values[i]))
879 if ((num == 0) /* All data sources are undefined. */
880 || (sum == 0.0)) /* Sum is zero, cannot calculate percentage. */
882 for (i = 0; i < ds->ds_num; i++)
883 values_copy[i] = NAN;
885 else /* We can actually calculate the percentage. */
887 for (i = 0; i < ds->ds_num; i++)
888 values_copy[i] = 100.0 * values[i] / sum;
890 } /* if (UT_FLAG_PERCENTAGE) */
892 for (i = 0; i < ds->ds_num; i++)
896 status = ut_check_one_data_source (ds, vl, th, values_copy, i);
902 } /* for (ds->ds_num) */
904 if (ret_ds_index != NULL)
905 *ret_ds_index = ds_index;
908 } /* }}} int ut_check_one_threshold */
911 * int ut_check_threshold (PUBLIC)
913 * Gets a list of matching thresholds and searches for the worst status by one
914 * of the thresholds. Then reports that status using the ut_report_state
916 * Returns zero on success and if no threshold has been configured. Returns
917 * less than zero on failure.
919 int ut_check_threshold (const data_set_t *ds, const value_list_t *vl)
925 int worst_state = -1;
926 threshold_t *worst_th = NULL;
927 int worst_ds_index = -1;
929 if (threshold_tree == NULL)
932 /* Is this lock really necessary? So far, thresholds are only inserted at
934 pthread_mutex_lock (&threshold_lock);
935 th = threshold_search (vl);
936 pthread_mutex_unlock (&threshold_lock);
940 DEBUG ("ut_check_threshold: Found matching threshold(s)");
942 values = uc_get_rate (ds, vl);
950 status = ut_check_one_threshold (ds, vl, th, values, &ds_index);
953 ERROR ("ut_check_threshold: ut_check_one_threshold failed.");
958 if (worst_state < status)
960 worst_state = status;
962 worst_ds_index = ds_index;
968 status = ut_report_state (ds, vl, worst_th, values,
969 worst_ds_index, worst_state);
972 ERROR ("ut_check_threshold: ut_report_state failed.");
980 } /* }}} int ut_check_threshold */
983 * int ut_check_interesting (PUBLIC)
985 * Given an identification returns
986 * 0: No threshold is defined.
987 * 1: A threshold has been found. The flag `persist' is off.
988 * 2: A threshold has been found. The flag `persist' is on.
989 * (That is, it is expected that many notifications are sent until the
990 * problem disappears.)
992 int ut_check_interesting (const char *name)
994 char *name_copy = NULL;
997 char *plugin_instance = NULL;
999 char *type_instance = NULL;
1005 /* If there is no tree nothing is interesting. */
1006 if (threshold_tree == NULL)
1009 name_copy = strdup (name);
1010 if (name_copy == NULL)
1012 ERROR ("ut_check_interesting: strdup failed.");
1016 status = parse_identifier (name_copy, &host,
1017 &plugin, &plugin_instance, &type, &type_instance);
1020 ERROR ("ut_check_interesting: parse_identifier failed.");
1025 memset (&ds, '\0', sizeof (ds));
1026 memset (&vl, '\0', sizeof (vl));
1028 sstrncpy (vl.host, host, sizeof (vl.host));
1029 sstrncpy (vl.plugin, plugin, sizeof (vl.plugin));
1030 if (plugin_instance != NULL)
1031 sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
1032 sstrncpy (ds.type, type, sizeof (ds.type));
1033 sstrncpy (vl.type, type, sizeof (vl.type));
1034 if (type_instance != NULL)
1035 sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
1038 host = plugin = plugin_instance = type = type_instance = NULL;
1040 th = threshold_search (&vl);
1043 if ((th->flags & UT_FLAG_PERSIST) == 0)
1046 } /* }}} int ut_check_interesting */
1048 /* vim: set sw=2 ts=8 sts=2 tw=78 et fdm=marker : */