summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27769fc)
raw | patch | inline | side by side (parent: 27769fc)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 17 Jun 2011 07:25:05 +0000 (09:25 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 17 Jun 2011 07:28:54 +0000 (09:28 +0200) |
The checking is fairly expensive, so don't do that unless really necessary.
src/threshold.c | patch | blob | history |
diff --git a/src/threshold.c b/src/threshold.c
index 88616e9501ab0abf7779122f610228e34237d4f8..342d08acae919edd72cbea74b10a6e798dc4a094 100644 (file)
--- a/src/threshold.c
+++ b/src/threshold.c
return (status);
} /* int ut_config_host */
-
-int ut_config (oconfig_item_t *ci)
-{
- int i;
- int status = 0;
-
- threshold_t th;
-
- if (threshold_tree == NULL)
- {
- threshold_tree = c_avl_create ((void *) strcmp);
- if (threshold_tree == NULL)
- {
- ERROR ("ut_config: c_avl_create failed.");
- return (-1);
- }
- }
-
- memset (&th, '\0', sizeof (th));
- th.warning_min = NAN;
- th.warning_max = NAN;
- th.failure_min = NAN;
- th.failure_max = NAN;
-
- th.hits = 0;
- th.hysteresis = 0;
- th.flags = UT_FLAG_INTERESTING; /* interesting by default */
-
- for (i = 0; i < ci->children_num; i++)
- {
- oconfig_item_t *option = ci->children + i;
- status = 0;
-
- if (strcasecmp ("Type", option->key) == 0)
- status = ut_config_type (&th, option);
- else if (strcasecmp ("Plugin", option->key) == 0)
- status = ut_config_plugin (&th, option);
- else if (strcasecmp ("Host", option->key) == 0)
- status = ut_config_host (&th, option);
- else
- {
- WARNING ("threshold values: Option `%s' not allowed here.", option->key);
- status = -1;
- }
-
- if (status != 0)
- break;
- }
-
- return (status);
-} /* int um_config */
/*
* End of the functions used to configure threshold values.
*/
return (0);
} /* }}} int ut_missing */
+int ut_config (oconfig_item_t *ci)
+{ /* {{{ */
+ int i;
+ int status = 0;
+
+ threshold_t th;
+
+ if (threshold_tree == NULL)
+ {
+ threshold_tree = c_avl_create ((void *) strcmp);
+ if (threshold_tree == NULL)
+ {
+ ERROR ("ut_config: c_avl_create failed.");
+ return (-1);
+ }
+ }
+
+ memset (&th, '\0', sizeof (th));
+ th.warning_min = NAN;
+ th.warning_max = NAN;
+ th.failure_min = NAN;
+ th.failure_max = NAN;
+
+ th.hits = 0;
+ th.hysteresis = 0;
+ th.flags = UT_FLAG_INTERESTING; /* interesting by default */
+
+ for (i = 0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *option = ci->children + i;
+ status = 0;
+
+ if (strcasecmp ("Type", option->key) == 0)
+ status = ut_config_type (&th, option);
+ else if (strcasecmp ("Plugin", option->key) == 0)
+ status = ut_config_plugin (&th, option);
+ else if (strcasecmp ("Host", option->key) == 0)
+ status = ut_config_host (&th, option);
+ else
+ {
+ WARNING ("threshold values: Option `%s' not allowed here.", option->key);
+ status = -1;
+ }
+
+ if (status != 0)
+ break;
+ }
+
+ if (c_avl_size (threshold_tree) > 0) {
+ plugin_register_missing ("threshold", ut_missing,
+ /* user data = */ NULL);
+ plugin_register_write ("threshold", ut_check_threshold,
+ /* user data = */ NULL);
+ }
+
+ return (status);
+} /* }}} int um_config */
+
void module_register (void)
{
plugin_register_complex_config ("threshold", ut_config);
- plugin_register_missing ("threshold", ut_missing,
- /* user data = */ NULL);
- plugin_register_write ("threshold", ut_check_threshold,
- /* user data = */ NULL);
}
/* vim: set sw=2 ts=8 sts=2 tw=78 et fdm=marker : */