2 * collectd - src/threshold.c
3 * Copyright (C) 2007-2010 Florian Forster
4 * Copyright (C) 2008-2009 Sebastian Harl
5 * Copyright (C) 2009 Andrés J. Díaz
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; only version 2 of the License is applicable.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Florian octo Forster <octo at collectd.org>
22 * Sebastian Harl <sh at tokkee.org>
23 * Andrés J. Díaz <ajdiaz at connectical.com>
29 #include "utils_avltree.h"
30 #include "utils_cache.h"
31 #include "utils_threshold.h"
37 * Threshold management
38 * ====================
39 * The following functions add, delete, search, etc. configured thresholds to
40 * the underlying AVL trees.
43 * threshold_t *threshold_get
45 * Retrieve one specific threshold configuration. For looking up a threshold
46 * matching a value_list_t, see "threshold_search" below. Returns NULL if the
47 * specified threshold doesn't exist.
49 static threshold_t *threshold_get (const char *hostname,
50 const char *plugin, const char *plugin_instance,
51 const char *type, const char *type_instance)
53 char name[6 * DATA_MAX_NAME_LEN];
54 threshold_t *th = NULL;
56 format_name (name, sizeof (name),
57 (hostname == NULL) ? "" : hostname,
58 (plugin == NULL) ? "" : plugin, plugin_instance,
59 (type == NULL) ? "" : type, type_instance);
60 name[sizeof (name) - 1] = '\0';
62 if (c_avl_get (threshold_tree, name, (void *) &th) == 0)
66 } /* }}} threshold_t *threshold_get */
69 * int ut_threshold_add
71 * Adds a threshold configuration to the list of thresholds. The threshold_t
72 * structure is copied and may be destroyed after this call. Returns zero on
73 * success, non-zero otherwise.
75 static int ut_threshold_add (const threshold_t *th)
77 char name[6 * DATA_MAX_NAME_LEN];
83 if (format_name (name, sizeof (name), th->host,
84 th->plugin, th->plugin_instance,
85 th->type, th->type_instance) != 0)
87 ERROR ("ut_threshold_add: format_name failed.");
91 name_copy = strdup (name);
92 if (name_copy == NULL)
94 ERROR ("ut_threshold_add: strdup failed.");
98 th_copy = (threshold_t *) malloc (sizeof (threshold_t));
102 ERROR ("ut_threshold_add: malloc failed.");
105 memcpy (th_copy, th, sizeof (threshold_t));
108 DEBUG ("ut_threshold_add: Adding entry `%s'", name);
110 pthread_mutex_lock (&threshold_lock);
112 th_ptr = threshold_get (th->host, th->plugin, th->plugin_instance,
113 th->type, th->type_instance);
115 while ((th_ptr != NULL) && (th_ptr->next != NULL))
116 th_ptr = th_ptr->next;
118 if (th_ptr == NULL) /* no such threshold yet */
120 status = c_avl_insert (threshold_tree, name_copy, th_copy);
122 else /* th_ptr points to the last threshold in the list */
124 th_ptr->next = th_copy;
125 /* name_copy isn't needed */
129 pthread_mutex_unlock (&threshold_lock);
133 ERROR ("ut_threshold_add: c_avl_insert (%s) failed.", name);
139 } /* }}} int ut_threshold_add */
142 * threshold_t *threshold_search
144 * Searches for a threshold configuration using all the possible variations of
145 * "Host", "Plugin" and "Type" blocks. Returns NULL if no threshold could be
147 * XXX: This is likely the least efficient function in collectd.
149 static threshold_t *threshold_search (const value_list_t *vl)
153 if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
154 vl->type, vl->type_instance)) != NULL)
156 else if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
157 vl->type, NULL)) != NULL)
159 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
160 vl->type, vl->type_instance)) != NULL)
162 else if ((th = threshold_get (vl->host, vl->plugin, NULL,
163 vl->type, NULL)) != NULL)
165 else if ((th = threshold_get (vl->host, "", NULL,
166 vl->type, vl->type_instance)) != NULL)
168 else if ((th = threshold_get (vl->host, "", NULL,
169 vl->type, NULL)) != NULL)
171 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
172 vl->type, vl->type_instance)) != NULL)
174 else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
175 vl->type, NULL)) != NULL)
177 else if ((th = threshold_get ("", vl->plugin, NULL,
178 vl->type, vl->type_instance)) != NULL)
180 else if ((th = threshold_get ("", vl->plugin, NULL,
181 vl->type, NULL)) != NULL)
183 else if ((th = threshold_get ("", "", NULL,
184 vl->type, vl->type_instance)) != NULL)
186 else if ((th = threshold_get ("", "", NULL,
187 vl->type, NULL)) != NULL)
191 } /* }}} threshold_t *threshold_search */
196 * The following approximately two hundred functions are used to handle the
197 * configuration and fill the threshold list.
199 static int ut_config_type_datasource (threshold_t *th, oconfig_item_t *ci)
201 if ((ci->values_num != 1)
202 || (ci->values[0].type != OCONFIG_TYPE_STRING))
204 WARNING ("threshold values: The `DataSource' option needs exactly one "
209 sstrncpy (th->data_source, ci->values[0].value.string,
210 sizeof (th->data_source));
213 } /* int ut_config_type_datasource */
215 static int ut_config_type_instance (threshold_t *th, oconfig_item_t *ci)
217 if ((ci->values_num != 1)
218 || (ci->values[0].type != OCONFIG_TYPE_STRING))
220 WARNING ("threshold values: The `Instance' option needs exactly one "
225 sstrncpy (th->type_instance, ci->values[0].value.string,
226 sizeof (th->type_instance));
229 } /* int ut_config_type_instance */
231 static int ut_config_type_max (threshold_t *th, oconfig_item_t *ci)
233 if ((ci->values_num != 1)
234 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
236 WARNING ("threshold values: The `%s' option needs exactly one "
237 "number argument.", ci->key);
241 if (strcasecmp (ci->key, "WarningMax") == 0)
242 th->warning_max = ci->values[0].value.number;
244 th->failure_max = ci->values[0].value.number;
247 } /* int ut_config_type_max */
249 static int ut_config_type_min (threshold_t *th, oconfig_item_t *ci)
251 if ((ci->values_num != 1)
252 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
254 WARNING ("threshold values: The `%s' option needs exactly one "
255 "number argument.", ci->key);
259 if (strcasecmp (ci->key, "WarningMin") == 0)
260 th->warning_min = ci->values[0].value.number;
262 th->failure_min = ci->values[0].value.number;
265 } /* int ut_config_type_min */
267 static int ut_config_type_hits (threshold_t *th, oconfig_item_t *ci)
269 if ((ci->values_num != 1)
270 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
272 WARNING ("threshold values: The `%s' option needs exactly one "
273 "number argument.", ci->key);
277 th->hits = ci->values[0].value.number;
280 } /* int ut_config_type_hits */
282 static int ut_config_type_hysteresis (threshold_t *th, oconfig_item_t *ci)
284 if ((ci->values_num != 1)
285 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
287 WARNING ("threshold values: The `%s' option needs exactly one "
288 "number argument.", ci->key);
292 th->hysteresis = ci->values[0].value.number;
295 } /* int ut_config_type_hysteresis */
297 static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci)
303 if ((ci->values_num != 1)
304 || (ci->values[0].type != OCONFIG_TYPE_STRING))
306 WARNING ("threshold values: The `Type' block needs exactly one string "
311 if (ci->children_num < 1)
313 WARNING ("threshold values: The `Type' block needs at least one option.");
317 memcpy (&th, th_orig, sizeof (th));
318 sstrncpy (th.type, ci->values[0].value.string, sizeof (th.type));
320 th.warning_min = NAN;
321 th.warning_max = NAN;
322 th.failure_min = NAN;
323 th.failure_max = NAN;
326 th.flags = UT_FLAG_INTERESTING; /* interesting by default */
328 for (i = 0; i < ci->children_num; i++)
330 oconfig_item_t *option = ci->children + i;
333 if (strcasecmp ("Instance", option->key) == 0)
334 status = ut_config_type_instance (&th, option);
335 else if (strcasecmp ("DataSource", option->key) == 0)
336 status = ut_config_type_datasource (&th, option);
337 else if ((strcasecmp ("WarningMax", option->key) == 0)
338 || (strcasecmp ("FailureMax", option->key) == 0))
339 status = ut_config_type_max (&th, option);
340 else if ((strcasecmp ("WarningMin", option->key) == 0)
341 || (strcasecmp ("FailureMin", option->key) == 0))
342 status = ut_config_type_min (&th, option);
343 else if (strcasecmp ("Interesting", option->key) == 0)
344 status = cf_util_get_flag (option, &th.flags, UT_FLAG_INTERESTING);
345 else if (strcasecmp ("Invert", option->key) == 0)
346 status = cf_util_get_flag (option, &th.flags, UT_FLAG_INVERT);
347 else if (strcasecmp ("Persist", option->key) == 0)
348 status = cf_util_get_flag (option, &th.flags, UT_FLAG_PERSIST);
349 else if (strcasecmp ("PersistOK", option->key) == 0)
350 status = cf_util_get_flag (option, &th.flags, UT_FLAG_PERSIST_OK);
351 else if (strcasecmp ("Percentage", option->key) == 0)
352 status = cf_util_get_flag (option, &th.flags, UT_FLAG_PERCENTAGE);
353 else if (strcasecmp ("Hits", option->key) == 0)
354 status = ut_config_type_hits (&th, option);
355 else if (strcasecmp ("Hysteresis", option->key) == 0)
356 status = ut_config_type_hysteresis (&th, option);
359 WARNING ("threshold values: Option `%s' not allowed inside a `Type' "
360 "block.", option->key);
370 status = ut_threshold_add (&th);
374 } /* int ut_config_type */
376 static int ut_config_plugin_instance (threshold_t *th, oconfig_item_t *ci)
378 if ((ci->values_num != 1)
379 || (ci->values[0].type != OCONFIG_TYPE_STRING))
381 WARNING ("threshold values: The `Instance' option needs exactly one "
386 sstrncpy (th->plugin_instance, ci->values[0].value.string,
387 sizeof (th->plugin_instance));
390 } /* int ut_config_plugin_instance */
392 static int ut_config_plugin (const threshold_t *th_orig, oconfig_item_t *ci)
398 if ((ci->values_num != 1)
399 || (ci->values[0].type != OCONFIG_TYPE_STRING))
401 WARNING ("threshold values: The `Plugin' block needs exactly one string "
406 if (ci->children_num < 1)
408 WARNING ("threshold values: The `Plugin' block needs at least one nested "
413 memcpy (&th, th_orig, sizeof (th));
414 sstrncpy (th.plugin, ci->values[0].value.string, sizeof (th.plugin));
416 for (i = 0; i < ci->children_num; i++)
418 oconfig_item_t *option = ci->children + i;
421 if (strcasecmp ("Type", option->key) == 0)
422 status = ut_config_type (&th, option);
423 else if (strcasecmp ("Instance", option->key) == 0)
424 status = ut_config_plugin_instance (&th, option);
427 WARNING ("threshold values: Option `%s' not allowed inside a `Plugin' "
428 "block.", option->key);
437 } /* int ut_config_plugin */
439 static int ut_config_host (const threshold_t *th_orig, oconfig_item_t *ci)
445 if ((ci->values_num != 1)
446 || (ci->values[0].type != OCONFIG_TYPE_STRING))
448 WARNING ("threshold values: The `Host' block needs exactly one string "
453 if (ci->children_num < 1)
455 WARNING ("threshold values: The `Host' block needs at least one nested "
460 memcpy (&th, th_orig, sizeof (th));
461 sstrncpy (th.host, ci->values[0].value.string, sizeof (th.host));
463 for (i = 0; i < ci->children_num; i++)
465 oconfig_item_t *option = ci->children + i;
468 if (strcasecmp ("Type", option->key) == 0)
469 status = ut_config_type (&th, option);
470 else if (strcasecmp ("Plugin", option->key) == 0)
471 status = ut_config_plugin (&th, option);
474 WARNING ("threshold values: Option `%s' not allowed inside a `Host' "
475 "block.", option->key);
484 } /* int ut_config_host */
486 * End of the functions used to configure threshold values.
491 * int ut_report_state
493 * Checks if the `state' differs from the old state and creates a notification
497 static int ut_report_state (const data_set_t *ds,
498 const value_list_t *vl,
499 const threshold_t *th,
500 const gauge_t *values,
512 /* Check if hits matched */
513 if ( (th->hits != 0) )
515 int hits = uc_get_hits(ds,vl);
516 /* STATE_OKAY resets hits unless PERSIST_OK flag is set. Hits resets if
517 * threshold is hit. */
518 if ( ( (state == STATE_OKAY) && ((th->flags & UT_FLAG_PERSIST_OK) == 0) ) || (hits > th->hits) )
520 DEBUG("ut_report_state: reset uc_get_hits = 0");
521 uc_set_hits(ds,vl,0); /* reset hit counter and notify */
523 DEBUG("ut_report_state: th->hits = %d, uc_get_hits = %d",th->hits,uc_get_hits(ds,vl));
524 (void) uc_inc_hits(ds,vl,1); /* increase hit counter */
527 } /* end check hits */
529 state_old = uc_get_state (ds, vl);
531 /* If the state didn't change, report if `persistent' is specified. If the
532 * state is `okay', then only report if `persist_ok` flag is set. */
533 if (state == state_old)
535 if ((th->flags & UT_FLAG_PERSIST) == 0)
537 else if ( (state == STATE_OKAY) && ((th->flags & UT_FLAG_PERSIST_OK) == 0) )
541 if (state != state_old)
542 uc_set_state (ds, vl, state);
544 NOTIFICATION_INIT_VL (&n, vl);
547 bufsize = sizeof (n.message);
549 if (state == STATE_OKAY)
550 n.severity = NOTIF_OKAY;
551 else if (state == STATE_WARNING)
552 n.severity = NOTIF_WARNING;
554 n.severity = NOTIF_FAILURE;
558 status = ssnprintf (buf, bufsize, "Host %s, plugin %s",
559 vl->host, vl->plugin);
563 if (vl->plugin_instance[0] != '\0')
565 status = ssnprintf (buf, bufsize, " (instance %s)",
566 vl->plugin_instance);
571 status = ssnprintf (buf, bufsize, " type %s", vl->type);
575 if (vl->type_instance[0] != '\0')
577 status = ssnprintf (buf, bufsize, " (instance %s)",
583 plugin_notification_meta_add_string (&n, "DataSource",
584 ds->ds[ds_index].name);
585 plugin_notification_meta_add_double (&n, "CurrentValue", values[ds_index]);
586 plugin_notification_meta_add_double (&n, "WarningMin", th->warning_min);
587 plugin_notification_meta_add_double (&n, "WarningMax", th->warning_max);
588 plugin_notification_meta_add_double (&n, "FailureMin", th->failure_min);
589 plugin_notification_meta_add_double (&n, "FailureMax", th->failure_max);
591 /* Send an okay notification */
592 if (state == STATE_OKAY)
594 if (state_old == STATE_MISSING)
595 status = ssnprintf (buf, bufsize,
596 ": Value is no longer missing.");
598 status = ssnprintf (buf, bufsize,
599 ": All data sources are within range again.");
608 min = (state == STATE_ERROR) ? th->failure_min : th->warning_min;
609 max = (state == STATE_ERROR) ? th->failure_max : th->warning_max;
611 if (th->flags & UT_FLAG_INVERT)
613 if (!isnan (min) && !isnan (max))
615 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
616 "%f. That is within the %s region of %f%s and %f%s.",
617 ds->ds[ds_index].name, values[ds_index],
618 (state == STATE_ERROR) ? "failure" : "warning",
619 min, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "",
620 max, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
624 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
625 "%f. That is %s the %s threshold of %f%s.",
626 ds->ds[ds_index].name, values[ds_index],
627 isnan (min) ? "below" : "above",
628 (state == STATE_ERROR) ? "failure" : "warning",
629 isnan (min) ? max : min,
630 ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
633 else if (th->flags & UT_FLAG_PERCENTAGE)
640 for (i = 0; i < vl->values_len; i++)
642 if (isnan (values[i]))
651 value = 100.0 * values[ds_index] / sum;
653 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
654 "%g (%.2f%%). That is %s the %s threshold of %.2f%%.",
655 ds->ds[ds_index].name, values[ds_index], value,
656 (value < min) ? "below" : "above",
657 (state == STATE_ERROR) ? "failure" : "warning",
658 (value < min) ? min : max);
660 else /* is not inverted */
662 status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
663 "%f. That is %s the %s threshold of %f.",
664 ds->ds[ds_index].name, values[ds_index],
665 (values[ds_index] < min) ? "below" : "above",
666 (state == STATE_ERROR) ? "failure" : "warning",
667 (values[ds_index] < min) ? min : max);
673 plugin_dispatch_notification (&n);
675 plugin_notification_meta_free (n.meta);
677 } /* }}} int ut_report_state */
680 * int ut_check_one_data_source
682 * Checks one data source against the given threshold configuration. If the
683 * `DataSource' option is set in the threshold, and the name does NOT match,
684 * `okay' is returned. If the threshold does match, its failure and warning
685 * min and max values are checked and `failure' or `warning' is returned if
689 static int ut_check_one_data_source (const data_set_t *ds,
690 const value_list_t __attribute__((unused)) *vl,
691 const threshold_t *th,
692 const gauge_t *values,
698 int prev_state = STATE_OKAY;
700 /* check if this threshold applies to this data source */
703 ds_name = ds->ds[ds_index].name;
704 if ((th->data_source[0] != 0)
705 && (strcmp (ds_name, th->data_source) != 0))
709 if ((th->flags & UT_FLAG_INVERT) != 0)
715 /* XXX: This is an experimental code, not optimized, not fast, not reliable,
716 * and probably, do not work as you expect. Enjoy! :D */
717 if ( (th->hysteresis > 0) && ((prev_state = uc_get_state(ds,vl)) != STATE_OKAY) )
722 if ( (!isnan (th->failure_min) && ((th->failure_min + th->hysteresis) < values[ds_index])) ||
723 (!isnan (th->failure_max) && ((th->failure_max - th->hysteresis) > values[ds_index])) )
728 if ( (!isnan (th->warning_min) && ((th->warning_min + th->hysteresis) < values[ds_index])) ||
729 (!isnan (th->warning_max) && ((th->warning_max - th->hysteresis) > values[ds_index])) )
735 else { /* no hysteresis */
736 if ((!isnan (th->failure_min) && (th->failure_min > values[ds_index]))
737 || (!isnan (th->failure_max) && (th->failure_max < values[ds_index])))
740 if ((!isnan (th->warning_min) && (th->warning_min > values[ds_index]))
741 || (!isnan (th->warning_max) && (th->warning_max < values[ds_index])))
746 return (STATE_ERROR);
749 return (STATE_WARNING);
752 } /* }}} int ut_check_one_data_source */
755 * int ut_check_one_threshold
757 * Checks all data sources of a value list against the given threshold, using
758 * the ut_check_one_data_source function above. Returns the worst status,
759 * which is `okay' if nothing has failed.
760 * Returns less than zero if the data set doesn't have any data sources.
762 static int ut_check_one_threshold (const data_set_t *ds,
763 const value_list_t *vl,
764 const threshold_t *th,
765 const gauge_t *values,
771 gauge_t values_copy[ds->ds_num];
773 memcpy (values_copy, values, sizeof (values_copy));
775 if ((th->flags & UT_FLAG_PERCENTAGE) != 0)
782 WARNING ("ut_check_one_threshold: The %s type has only one data "
783 "source, but you have configured to check this as a percentage. "
784 "That doesn't make much sense, because the percentage will always "
785 "be 100%%!", ds->type);
788 /* Prepare `sum' and `num'. */
789 for (i = 0; i < ds->ds_num; i++)
790 if (!isnan (values[i]))
796 if ((num == 0) /* All data sources are undefined. */
797 || (sum == 0.0)) /* Sum is zero, cannot calculate percentage. */
799 for (i = 0; i < ds->ds_num; i++)
800 values_copy[i] = NAN;
802 else /* We can actually calculate the percentage. */
804 for (i = 0; i < ds->ds_num; i++)
805 values_copy[i] = 100.0 * values[i] / sum;
807 } /* if (UT_FLAG_PERCENTAGE) */
809 for (i = 0; i < ds->ds_num; i++)
813 status = ut_check_one_data_source (ds, vl, th, values_copy, i);
819 } /* for (ds->ds_num) */
821 if (ret_ds_index != NULL)
822 *ret_ds_index = ds_index;
825 } /* }}} int ut_check_one_threshold */
828 * int ut_check_threshold
830 * Gets a list of matching thresholds and searches for the worst status by one
831 * of the thresholds. Then reports that status using the ut_report_state
833 * Returns zero on success and if no threshold has been configured. Returns
834 * less than zero on failure.
836 static int ut_check_threshold (const data_set_t *ds, const value_list_t *vl,
837 __attribute__((unused)) user_data_t *ud)
843 int worst_state = -1;
844 threshold_t *worst_th = NULL;
845 int worst_ds_index = -1;
847 if (threshold_tree == NULL)
850 /* Is this lock really necessary? So far, thresholds are only inserted at
852 pthread_mutex_lock (&threshold_lock);
853 th = threshold_search (vl);
854 pthread_mutex_unlock (&threshold_lock);
858 DEBUG ("ut_check_threshold: Found matching threshold(s)");
860 values = uc_get_rate (ds, vl);
868 status = ut_check_one_threshold (ds, vl, th, values, &ds_index);
871 ERROR ("ut_check_threshold: ut_check_one_threshold failed.");
876 if (worst_state < status)
878 worst_state = status;
880 worst_ds_index = ds_index;
886 status = ut_report_state (ds, vl, worst_th, values,
887 worst_ds_index, worst_state);
890 ERROR ("ut_check_threshold: ut_report_state failed.");
898 } /* }}} int ut_check_threshold */
903 * This function is called whenever a value goes "missing".
905 static int ut_missing (const value_list_t *vl,
906 __attribute__((unused)) user_data_t *ud)
909 cdtime_t missing_time;
910 char identifier[6 * DATA_MAX_NAME_LEN];
913 if (threshold_tree == NULL)
916 th = threshold_search (vl);
917 /* dispatch notifications for "interesting" values only */
918 if ((th == NULL) || ((th->flags & UT_FLAG_INTERESTING) == 0))
921 missing_time = cdtime () - vl->time;
922 FORMAT_VL (identifier, sizeof (identifier), vl);
924 NOTIFICATION_INIT_VL (&n, vl);
925 ssnprintf (n.message, sizeof (n.message),
926 "%s has not been updated for %.3f seconds.",
927 identifier, CDTIME_T_TO_DOUBLE (missing_time));
929 plugin_dispatch_notification (&n);
932 } /* }}} int ut_missing */
934 int ut_config (oconfig_item_t *ci)
941 if (threshold_tree == NULL)
943 threshold_tree = c_avl_create ((void *) strcmp);
944 if (threshold_tree == NULL)
946 ERROR ("ut_config: c_avl_create failed.");
951 memset (&th, '\0', sizeof (th));
952 th.warning_min = NAN;
953 th.warning_max = NAN;
954 th.failure_min = NAN;
955 th.failure_max = NAN;
959 th.flags = UT_FLAG_INTERESTING; /* interesting by default */
961 for (i = 0; i < ci->children_num; i++)
963 oconfig_item_t *option = ci->children + i;
966 if (strcasecmp ("Type", option->key) == 0)
967 status = ut_config_type (&th, option);
968 else if (strcasecmp ("Plugin", option->key) == 0)
969 status = ut_config_plugin (&th, option);
970 else if (strcasecmp ("Host", option->key) == 0)
971 status = ut_config_host (&th, option);
974 WARNING ("threshold values: Option `%s' not allowed here.", option->key);
982 if (c_avl_size (threshold_tree) > 0) {
983 plugin_register_missing ("threshold", ut_missing,
984 /* user data = */ NULL);
985 plugin_register_write ("threshold", ut_check_threshold,
986 /* user data = */ NULL);
990 } /* }}} int um_config */
992 void module_register (void)
994 plugin_register_complex_config ("threshold", ut_config);
997 /* vim: set sw=2 ts=8 sts=2 tw=78 et fdm=marker : */