From 2739b2c65f22e459d947bdd10cb9a9807ca729e8 Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Wed, 19 Jul 2017 19:28:15 +0700 Subject: [PATCH] rrdtool plugin: Changes after review * Handle "CacheFlush" as a double * Updated documentation spelling --- src/collectd.conf.pod | 15 ++++++++------- src/rrdtool.c | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index f94669ad..784c4053 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -6472,13 +6472,14 @@ anymore for some reason (the computer was shut down, the network is broken, etc.) some values may still be in the cache. If B is set, then every I seconds the entire cache is searched for entries older than B + B seconds. The entries found are written to -disk. Since entire cache scan is kind of expensive and does nothing under normal -circumstances, this value should not be too small. 900 seconds might be a good -value, though setting this to 7200 seconds doesn't normally do much harm either. - -Default value for this option is 10x of B. -If value of B less than value of B then default value -used too. +disk. Since scanning the entire cache is kind of expensive and does nothing +under normal circumstances, this value should not be too small. 900 seconds +might be a good value, though setting this to 7200 seconds doesn't normally +do much harm either. + +Defaults to 10x B. +B must be larger than or equal to B, otherwise the +above default is used. =item B I diff --git a/src/rrdtool.c b/src/rrdtool.c index dd2df0fe..f12b1ce3 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -863,7 +863,7 @@ static int rrd_config(const char *key, const char *value) { } cache_timeout = DOUBLE_TO_CDTIME_T(tmp); } else if (strcasecmp("CacheFlush", key) == 0) { - int tmp = atoi(value); + double tmp = atof(value); if (tmp < 0) { fprintf(stderr, "rrdtool: `CacheFlush' must " "be greater than 0.\n"); @@ -871,7 +871,7 @@ static int rrd_config(const char *key, const char *value) { "be greater than 0.\n"); return (1); } - cache_flush_timeout = TIME_T_TO_CDTIME_T(tmp); + cache_flush_timeout = DOUBLE_TO_CDTIME_T(tmp); } else if (strcasecmp("DataDir", key) == 0) { char *tmp; size_t len; @@ -1054,11 +1054,11 @@ static int rrd_init(void) { random_timeout = 0; cache_flush_timeout = 0; } else if (cache_flush_timeout < cache_timeout) { - INFO("rrdtool plugin: \"CacheFlush %u\" is less than \"CacheTimeout %u\". " - "Ajusting \"CacheFlush\" to %u seconds.", - (unsigned int)CDTIME_T_TO_TIME_T(cache_flush_timeout), - (unsigned int)CDTIME_T_TO_TIME_T(cache_timeout), - (unsigned int)CDTIME_T_TO_TIME_T(cache_timeout * 10)); + INFO("rrdtool plugin: \"CacheFlush %.3f\" is less than \"CacheTimeout %.3f\". " + "Ajusting \"CacheFlush\" to %.3f seconds.", + CDTIME_T_TO_DOUBLE(cache_flush_timeout), + CDTIME_T_TO_DOUBLE(cache_timeout), + CDTIME_T_TO_DOUBLE(cache_timeout * 10)); cache_flush_timeout = 10 * cache_timeout; } -- 2.11.0