From: Andrés J. Díaz Date: Thu, 17 Dec 2009 22:21:14 +0000 (+0100) Subject: Timeout for missing values X-Git-Tag: collectd-4.10.0~13 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=26be7bb8e6eaab8d1b24a721a634d273337185af;p=collectd.git Timeout for missing values Hi! I attach here a patch which adds Timeout option in configuration file. This option is global (i.e. at the same level as Interval) and it's the max number of intervals that a package can be missed before a missing notification would be raised. By dafault collectd wait 2 intervals and it's a hardcoded value AFAIK, if plugin cannot get data for more than 2 intervals, then (if it's an interesting value), collectd send a missing notification. Setting Timeout to an high value you can be more tolerant with that missing. It's usefull on large networks. In my case, the company LAN is distributed on distant locations and sometimes (due to network issues) UDP packages are lost, I use the Timeout to be more tolerant to this networks fails. For example setting Internval to 10 and Timeout to 6, a missing notification will be raised only if none data was reported in last 60s. I hope that things explained well enough, and (who knows!) maybe this could be usefull to anybody ;) Regards, Andrés Signed-off-by: Florian Forster --- diff --git a/src/collectd.c b/src/collectd.c index abab10f9..9a4ba08c 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -41,6 +41,7 @@ */ char hostname_g[DATA_MAX_NAME_LEN]; int interval_g; +int timeout_g; #if HAVE_LIBKSTAT kstat_ctl_t *kc; #endif /* HAVE_LIBKSTAT */ @@ -148,6 +149,18 @@ static int init_global_variables (void) } DEBUG ("interval_g = %i;", interval_g); + str = global_option_get ("Timeout"); + if (str == NULL) + str = "10"; + timeout_g = atoi (str); + if (timeout_g <= 0) + { + fprintf (stderr, "Cannot set the timeout to a correct value.\n" + "Please check your settings.\n"); + return (-1); + } + DEBUG ("timeout_g = %i;", timeout_g); + if (init_hostname () != 0) return (-1); DEBUG ("hostname_g = %s;", hostname_g); diff --git a/src/collectd.h b/src/collectd.h index 957654bc..8849b30b 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -300,5 +300,6 @@ typedef bool _Bool; extern char hostname_g[]; extern int interval_g; +extern int timeout_g; #endif /* COLLECTD_H */ diff --git a/src/configfile.c b/src/configfile.c index fe2bce3c..787ad0ea 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -99,6 +99,7 @@ static cf_global_option_t cf_global_options[] = {"FQDNLookup", NULL, "false"}, {"Interval", NULL, "10"}, {"ReadThreads", NULL, "5"}, + {"Timeout", NULL, "2"}, {"PreCacheChain", NULL, "PreCache"}, {"PostCacheChain", NULL, "PostCache"} }; diff --git a/src/utils_cache.c b/src/utils_cache.c index 648c54de..69ea864b 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -319,7 +319,7 @@ int uc_check_timeout (void) while (c_avl_iterator_next (iter, (void *) &key, (void *) &ce) == 0) { /* If entry has not been updated, add to `keys' array */ - if ((now - ce->last_update) >= (2 * ce->interval)) + if ((now - ce->last_update) >= (timeout_g * ce->interval)) { char **tmp;