Here a patch from Bruno Prémon to have these options in rrdcached plugin.
Cyril Le 22.03.2012 11:16, Stian Øvrevåge a écrit : > Hi, > > In the documentation there are some options for the rrdtool plugin > with regards to StepSize and some RRA-specifics. I am dependent on > tuning these values. However, I'm using the rrdcached plugin, not > rrdtool. How to proceed? > > Thanks in advance > > Regards, > Stian Øvrevåge > > _______________________________________________ > collectd mailing list > [email protected] [1] > http://mailman.verplant.org/listinfo/collectd [2] Links: ------ [1] mailto:[email protected] [2] http://mailman.verplant.org/listinfo/collectd
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 <[email protected]> --- --- 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 [email protected] http://mailman.verplant.org/listinfo/collectd
