Hi On Thu, 23 February 2012 colle...@faxm0dem.org wrote: > I had the exact same thought, and added the feature to my todolist. > Maybe octo could shed some light on the roadmap concerning rrdtool plugin > and its own cache vs. rrdcached plugin. What are your plans? I mean there's > no good reason to keep the code duplication, is there?
I've written and am using the attached patch for a while now. It applies as well to 4.10.3 as to 5.0.1 (did not yet check for newer bugfix releases but should apply there too) Florian, could you apply it to both branches? Regards, Bruno > On Tue, Feb 21, 2012 at 09:20:37PM +0200, Cyril Feraudet wrote: > > > > > > Hi All, > > > > Except mistake of me, we can't use both rrdtool and > > rrdcached plugins together. > > > > Since "rrdcached" plugin haven't "rrdtool" > > plugin options (RRATimespan, RRARows, etc), how to have > > > > custom RRD > > when using rrdcached ? > > > > I actually have custom RRD with rrdcached, but > > I did that by modifying "src/utils_rrdcreate.c" badly. > > > > Have you an > > idea to do it cleaner ? I may be missed something obvious ... > > > > Regards, > > > > > > Cyril
Make RRD settings configurable with rrdcached Copy over the RRD settings configuration options of rrdtool plugin to rrdcached plugin so the RRD step size, heartbeat and friends can also be configured for rrdcached. Signed-off-by: Bruno Prémont <bonb...@linux-vserver.org> --- --- collectd-4.10.3/src/rrdcached.c.orig 2011-04-14 14:50:46.917963666 +0200 +++ collectd-4.10.3/src/rrdcached.c 2011-04-14 15:35:20.243294587 +0200 @@ -36,7 +36,12 @@ static const char *config_keys[] = "DaemonAddress", "DataDir", "CreateFiles", - "CollectStatistics" + "CollectStatistics", + "StepSize", + "HeartBeat", + "RRARows", + "RRATimespan", + "XFF", }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); @@ -160,6 +165,19 @@ static int value_list_to_filename (char return (0); } /* int value_list_to_filename */ +static int rrd_compare_numeric (const void *a_ptr, const void *b_ptr) +{ + int a = *((int *) a_ptr); + int b = *((int *) b_ptr); + + if (a < b) + return (-1); + else if (a > b) + return (1); + else + return (0); +} /* int rrd_compare_numeric */ + static int rc_config (const char *key, const char *value) { if (strcasecmp ("DataDir", key) == 0) @@ -206,6 +224,83 @@ static int rc_config (const char *key, c else config_collect_stats = 1; } + else if (strcasecmp ("StepSize", key) == 0) + { + int temp = atoi (value); + if (temp > 0) + rrdcreate_config.stepsize = temp; + } + else if (strcasecmp ("HeartBeat", key) == 0) + { + int temp = atoi (value); + if (temp > 0) + rrdcreate_config.heartbeat = temp; + } + else if (strcasecmp ("RRARows", key) == 0) + { + int tmp = atoi (value); + if (tmp <= 0) + { + fprintf (stderr, "rrdtool: `RRARows' must " + "be greater than 0.\n"); + ERROR ("rrdtool: `RRARows' must " + "be greater than 0.\n"); + return (1); + } + rrdcreate_config.rrarows = tmp; + } + else if (strcasecmp ("RRATimespan", key) == 0) + { + char *saveptr = NULL; + char *dummy; + char *ptr; + char *value_copy; + int *tmp_alloc; + + value_copy = strdup (value); + if (value_copy == NULL) + return (1); + + dummy = value_copy; + while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL) + { + dummy = NULL; + + tmp_alloc = realloc (rrdcreate_config.timespans, + sizeof (int) * (rrdcreate_config.timespans_num + 1)); + if (tmp_alloc == NULL) + { + fprintf (stderr, "rrdtool: realloc failed.\n"); + ERROR ("rrdtool: realloc failed.\n"); + free (value_copy); + return (1); + } + rrdcreate_config.timespans = tmp_alloc; + rrdcreate_config.timespans[rrdcreate_config.timespans_num] = atoi (ptr); + if (rrdcreate_config.timespans[rrdcreate_config.timespans_num] != 0) + rrdcreate_config.timespans_num++; + } /* while (strtok_r) */ + + qsort (/* base = */ rrdcreate_config.timespans, + /* nmemb = */ rrdcreate_config.timespans_num, + /* size = */ sizeof (rrdcreate_config.timespans[0]), + /* compar = */ rrd_compare_numeric); + + free (value_copy); + } + else if (strcasecmp ("XFF", key) == 0) + { + double tmp = atof (value); + if ((tmp < 0.0) || (tmp >= 1.0)) + { + fprintf (stderr, "rrdtool: `XFF' must " + "be in the range 0 to 1 (exclusive)."); + ERROR ("rrdtool: `XFF' must " + "be in the range 0 to 1 (exclusive)."); + return (1); + } + rrdcreate_config.xff = tmp; + } else { return (-1);
_______________________________________________ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd