From: Florian Forster Date: Sat, 10 Nov 2012 08:51:24 +0000 (+0100) Subject: rrdcached plugin: Implement the "RRATimespan" option. X-Git-Tag: collectd-5.2.0~27 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ee74dd28301740b9b6f816bff3a2dbaa601953c4;p=collectd.git rrdcached plugin: Implement the "RRATimespan" option. --- diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 25a6c06e..9a670681 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4225,6 +4225,14 @@ one CDP by calculating: Bottom line is, set this no smaller than the width of you graphs in pixels. The default is 1200. +=item B I + +Adds an RRA-timespan, given in seconds. Use this option multiple times to have +more then one RRA. If this option is never used, the built-in default of (3600, +86400, 604800, 2678400, 31622400) is used. + +For more information on how RRA-sizes are calculated see B above. + =back =head2 Plugin C diff --git a/src/rrdcached.c b/src/rrdcached.c index a3dff3e9..3731d010 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -176,6 +176,26 @@ static int rc_config_get_int_positive (oconfig_item_t const *ci, int *ret) return (0); } /* int rc_config_get_int_positive */ +static int rc_config_add_timespan (int timespan) +{ + int *tmp; + + if (timespan <= 0) + return (EINVAL); + + tmp = realloc (rrdcreate_config.timespans, + sizeof (*rrdcreate_config.timespans) + * (rrdcreate_config.timespans_num + 1)); + if (tmp == NULL) + return (ENOMEM); + rrdcreate_config.timespans = tmp; + + rrdcreate_config.timespans[rrdcreate_config.timespans_num] = timespan; + rrdcreate_config.timespans_num++; + + return (0); +} /* int rc_config_add_timespan */ + static int rc_config (oconfig_item_t *ci) { int i; @@ -215,6 +235,13 @@ static int rc_config (oconfig_item_t *ci) status = rc_config_get_int_positive (child, &rrdcreate_config.heartbeat); else if (strcasecmp ("RRARows", key) == 0) status = rc_config_get_int_positive (child, &rrdcreate_config.rrarows); + else if (strcasecmp ("RRATimespan", key) == 0) + { + int tmp = -1; + status = rc_config_get_int_positive (child, &tmp); + if (status == 0) + status = rc_config_add_timespan (tmp); + } else { WARNING ("rrdcached plugin: Ignoring invalid option %s.", key);