From 36c6683fe0b8bb653339f3c854a18276344e4ac0 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 19 Dec 2007 15:07:10 +0100 Subject: [PATCH 1/1] src/utils_threshold.c: Implemented the new `Persist' option. The idea is that, if the option is set to `true', many notifications will be sent, until the problem vanishes again. If set to `false' only one notification will be sent upon a state change. This, however, is not implemented yet. --- src/collectd.conf.pod | 11 +++++++++++ src/utils_threshold.c | 27 ++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 44338c6f..447870d7 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1117,6 +1117,17 @@ If set to B the range of acceptable values is inverted, i.Ee. values between B and B are not okay. Defaults, of course, to B. +=item B B|B + +Sets how often notifications are generated. If set to B one notification +will be generated for each value that is out of the acceptable range. If set to +B (the default) then a notification is only generated if a value is out +of range but the previous value was okay. + +This applies to missing values, too: If set to B a notification about a +missing value is generated once every B seconds. If set to B +only one such notification is generated until the value appears again. + =back =head1 SEE ALSO diff --git a/src/utils_threshold.c b/src/utils_threshold.c index d7792f7c..4c439351 100644 --- a/src/utils_threshold.c +++ b/src/utils_threshold.c @@ -181,6 +181,24 @@ static int ut_config_type_invert (threshold_t *th, oconfig_item_t *ci) return (0); } /* int ut_config_type_invert */ +static int ut_config_type_persist (threshold_t *th, oconfig_item_t *ci) +{ + if ((ci->values_num != 1) + || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) + { + WARNING ("threshold values: The `Persist' option needs exactly one " + "boolean argument."); + return (-1); + } + + if (ci->values[0].value.boolean) + th->flags |= UT_FLAG_PERSIST; + else + th->flags &= ~UT_FLAG_PERSIST; + + return (0); +} /* int ut_config_type_persist */ + static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci) { int i; @@ -221,6 +239,8 @@ static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci) status = ut_config_type_min (&th, option); else if (strcasecmp ("Invert", option->key) == 0) status = ut_config_type_invert (&th, option); + else if (strcasecmp ("Persist", option->key) == 0) + status = ut_config_type_persist (&th, option); else { WARNING ("threshold values: Option `%s' not allowed inside a `Type' " @@ -637,10 +657,11 @@ int ut_check_interesting (const char *name) host = plugin = plugin_instance = type = type_instance = NULL; th = threshold_search (&ds, &vl); - if (th != NULL) - return (1); - else + if (th == NULL) return (0); + if ((th->flags & UT_FLAG_PERSIST) == 0) + return (1); + return (2); } /* int ut_check_interesting */ /* vim: set sw=2 ts=8 sts=2 tw=78 fdm=marker : */ -- 2.11.0