ds_def_t *ds_def,
void *key_hash,
long (*lookup)(void *, char *),
- mapping_t *mapping
- )
+ mapping_t *mapping,
+ const char **require_version)
{
int rc = -1;
char *dst_tmp = NULL;
dst_tmp = strndup(def + s, e - s);
dst_args = strndup(def + s2, e2 - s2);
+ if ((dst_conv(dst_tmp) == DST_DCOUNTER || dst_conv(dst_tmp) == DST_DDERIVE) &&
+ (*require_version == NULL || atoi(*require_version) < atoi(RRD_VERSION5))) {
+ *require_version = RRD_VERSION5;
+ }
+
switch (dst_conv(dst_tmp)) {
case DST_COUNTER:
case DST_ABSOLUTE:
int parseRRA(const char *def,
rra_def_t *rra_def,
rrd_t *rrd,
- unsigned long hash) {
+ unsigned long hash,
+ const char **require_version) {
char *argvcopy;
char *tokptr = "";
unsigned short token_idx, error_flag, period = 0;
int cf_id = -1;
int token_min = 4;
const char *parsetime_error = NULL;
- char *require_version = NULL;
memset(rra_def, 0, sizeof(rra_def_t));
cf_id = cf_conv(rra_def->cf_nam);
switch (cf_id) {
case CF_MHWPREDICT:
- require_version = RRD_VERSION; /* MHWPREDICT causes Version 4 */
+ if (*require_version == NULL || atoi(*require_version) < atoi(RRD_VERSION4)) {
+ *require_version = RRD_VERSION4; /* MHWPREDICT causes Version 4 */
+ }
case CF_HWPREDICT:
token_min = 5;
/* initialize some parameters */
if (sscanf(token, "smoothing-window=%lf",
&(rra_def->par[RRA_seasonal_smoothing_window].
u_val))) {
- require_version = RRD_VERSION; /* smoothing-window causes Version 4 */
+ if (*require_version == NULL || atoi(require_version) < atoi(RRD_VERSION4)) {
+ *require_version = RRD_VERSION4; /* smoothing-window causes Version 4 */
+ }
if (rra_def->par[RRA_seasonal_smoothing_window].u_val < 0.0
|| rra_def->par[RRA_seasonal_smoothing_window].u_val >
1.0) {
return(-1);
}
- // parsing went well. ONLY THEN are we allowed to produce
- // additional side effects.
- if (require_version != NULL) {
- if (rrd) {
- strcpy(rrd->stat_head->version, RRD_VERSION);
- }
- }
-
#ifdef DEBUG
fprintf(stderr,
"Creating RRA CF: %s, dep idx %lu\n",
GList *sources_rrd_files = NULL;
mapping_t *mappings = NULL;
int mappings_cnt = 0;
+ const char *require_version = NULL;
/* clear any previous errors */
rrd_clear_error();
memset(&rrd.ds_def[rrd.stat_head->ds_cnt], 0, sizeof(ds_def_t));
parseDS(argv[i] + 3, rrd.ds_def + rrd.stat_head->ds_cnt,
- &rrd, lookup_DS, &m);
+ &rrd, lookup_DS, &m, &require_version);
mappings = realloc(mappings, sizeof(mapping_t) * (mappings_cnt + 1));
if (! mappings) {
}
parseRRA(argv[i], rrd.rra_def + rrd.stat_head->rra_cnt, &rrd,
- hashed_name);
+ hashed_name, &require_version);
if (rrd_test_error()) {
goto done;
goto done;
}
}
-
+ // parsing went well. ONLY THEN are we allowed to produce
+ // additional side effects.
+ if (require_version != NULL) {
+ strcpy(rrd.stat_head->version, require_version);
+ }
if (rrd.stat_head->rra_cnt < 1) {
rrd_set_error("you must define at least one Round Robin Archive");
ds_def_t *ds_def,
void *key_hash,
long (*lookup)(void *, char *),
- mapping_t *mapping);
+ mapping_t *mapping,
+ const char **require_version);
/* Parse a textual RRA definition into rra_def. The rra_def might be
disconnected from any RRD. However, because some definitions cause
int parseRRA(const char *def,
rra_def_t *rra_def,
rrd_t *rrd,
- unsigned long hash);
+ unsigned long hash,
+ const char **require_version);
rra_def_t *handle_dependent_rras(rra_def_t *rra_def_array,
long unsigned int *rra_cnt,
if (atoi(rrd.stat_head->version) <= 3) {
CB_FMTS("\t<version>%s</version>\n", RRD_VERSION3);
} else {
- CB_FMTS("\t<version>%s</version>\n", RRD_VERSION);
+ CB_FMTS("\t<version>%s</version>\n", rrd.stat_head->version);
}
CB_FMTS("\t<step>%lu</step> <!-- Seconds -->\n",
#define RRD_COOKIE "RRD"
/* #define RRD_VERSION "0002" */
/* changed because microsecond precision requires another field */
-#define RRD_VERSION "0004"
#define RRD_VERSION3 "0003"
+#define RRD_VERSION4 "0004"
+#define RRD_VERSION5 "0005"
#define FLOAT_COOKIE ((double)8.642135E130)
typedef union unival {
int rc = -1;
int j;
const char *c;
+ const char *require_version = NULL;
+
for (j = 0, c = addDS[j] ; c ; j++, c = addDS[j]) {
ds_def_t added;
// parse DS
parseDS(c + 3,
&added, // out.ds_def + out.stat_head->ds_cnt,
- out, lookup_DS, NULL);
+ out, lookup_DS, NULL, &require_version);
// check if there is a name clash with an existing DS
if (lookup_DS(&out, added.ds_nam) >= 0) {
files should be modified, a dump/restore cycle should be
done.... */
- if (! (strcmp(in->stat_head->version, RRD_VERSION3) == 0 || strcmp(in->stat_head->version, RRD_VERSION) == 0) ) {
- rrd_set_error("direct modification is only supported for version 3 or version 4 RRD files. Consider to dump/restore before retrying a modification");
+ if (atoi(in->stat_head->version) < atoi(RRD_VERSION3) || atoi(in->stat_head->version) > atoi(RRD_VERSION5)) {
+ rrd_set_error("direct modification is only supported for version 3, 4 or 5 of RRD files. Consider to dump/restore before retrying a modification");
goto done;
}
unsigned int last_rra_cnt = out->stat_head->rra_cnt;
int total_out_rra_rows = 0;
int total_cnt_out = 0;
+ const char *require_version = NULL;
memset(&empty_cdp_prep, 0, sizeof(cdp_prep_t));
rra_def_t rra_def;
// the hash doesn't really matter...
- parseRRA(rra_mod_ops[r].def, &rra_def, out, hash);
+ parseRRA(rra_mod_ops[r].def, &rra_def, out, hash, &require_version);
if (rrd_test_error()) {
// failed!!!
}
}
+ if (require_version != NULL && atoi(require_version) < atoi(out->stat_head->version)) {
+ strcpy(out->stat_head->version, require_version);
+ }
+
if (last_rra_cnt < out->stat_head->rra_cnt) {
// extend cdp_prep and rra_ptr arrays
out->cdp_prep = (cdp_prep_t *) realloc(out->cdp_prep,
version = atoi(rrd->stat_head->version);
- if (version > atoi(RRD_VERSION)) {
+ if (version > atoi(RRD_VERSION5)) {
rrd_set_error("can't handle RRD file version %s",
rrd->stat_head->version);
goto out_nullify_head;
}
break;
case 's':
- strcpy(rrd.stat_head->version, RRD_VERSION); /* smoothing_window causes Version 4 */
+ if (atoi(rrd.stat_head->version) < atoi(RRD_VERSION4)) {
+ strcpy(rrd.stat_head->version, RRD_VERSION4); /* smoothing_window causes Version 4 */
+ }
if (set_hwsmootharg
(&rrd, CF_SEASONAL, RRA_seasonal_smoothing_window, optarg)) {
goto done;
}
break;
case 'S':
- strcpy(rrd.stat_head->version, RRD_VERSION); /* smoothing_window causes Version 4 */
+ if (atoi(rrd.stat_head->version) < atoi(RRD_VERSION4)) {
+ strcpy(rrd.stat_head->version, RRD_VERSION4); /* smoothing_window causes Version 4 */
+ }
if (set_hwsmootharg
(&rrd, CF_DEVSEASONAL, RRA_seasonal_smoothing_window,
optarg)) {