- eat_tag(&ptr2, "cdp_prep");
- for (i = 0; i < (int) rrd->stat_head->ds_cnt; i++) {
- eat_tag(&ptr2, "ds");
- /* support to read CDP parameters */
- rra_index = rrd->stat_head->rra_cnt - 1;
- skip(&ptr2);
- if (input_version < 2) {
- rrd->cdp_prep[rrd->stat_head->ds_cnt * (rra_index) +
- i].scratch[CDP_primary_val].u_val = 0.0;
- rrd->cdp_prep[rrd->stat_head->ds_cnt * (rra_index) +
- i].scratch[CDP_secondary_val].u_val = 0.0;
- read_tag(&ptr2, "value", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt * (rra_index) +
- i].scratch[CDP_val].u_val));
- read_tag(&ptr2, "unknown_datapoints", "%lu",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt * (rra_index) +
- i].scratch[CDP_unkn_pdp_cnt].u_cnt));
- } else {
-
- if (strncmp(ptr2, "<value>", 7) == 0) {
- parse_patch1028_CDP_params(&ptr2, rrd, rra_index, i);
- } else {
- read_tag(&ptr2, "primary_value", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt * (rra_index)
- + i].scratch[CDP_primary_val].u_val));
- read_tag(&ptr2, "secondary_value", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt * (rra_index)
- +
- i].scratch[CDP_secondary_val].u_val));
- switch (cf_conv(rrd->rra_def[rra_index].cf_nam)) {
- case CF_HWPREDICT:
- case CF_MHWPREDICT:
- read_tag(&ptr2, "intercept", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_intercept].
- u_val));
- read_tag(&ptr2, "last_intercept", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_last_intercept].
- u_val));
- read_tag(&ptr2, "slope", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_slope].u_val));
- read_tag(&ptr2, "last_slope", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_last_slope].
- u_val));
- read_tag(&ptr2, "nan_count", "%lu",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_null_count].
- u_cnt));
- read_tag(&ptr2, "last_nan_count", "%lu",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_last_null_count].
- u_cnt));
- break;
- case CF_SEASONAL:
- case CF_DEVSEASONAL:
- read_tag(&ptr2, "seasonal", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_seasonal].
- u_val));
- read_tag(&ptr2, "last_seasonal", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_hw_last_seasonal].
- u_val));
- read_tag(&ptr2, "init_flag", "%lu",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index)
- +
- i].scratch[CDP_init_seasonal].
- u_cnt));
- break;
- case CF_DEVPREDICT:
- break;
- case CF_FAILURES:
- parse_FAILURES_history(&ptr2, rrd, rra_index, i);
- break;
- case CF_AVERAGE:
- case CF_MAXIMUM:
- case CF_MINIMUM:
- case CF_LAST:
- default:
- read_tag(&ptr2, "value", "%lf",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index) +
- i].scratch[CDP_val].u_val));
- read_tag(&ptr2, "unknown_datapoints", "%lu",
- &(rrd->
- cdp_prep[rrd->stat_head->ds_cnt *
- (rra_index) +
- i].scratch[CDP_unkn_pdp_cnt].
- u_cnt));
- break;
- }
- }
- }
- eat_tag(&ptr2, "/ds");
+ return (status);
+} /* int parse_tag_rra_params */
+
+/*
+ * Parse an RRA definition
+ */
+static int parse_tag_rra_cf(
+ xmlDoc * doc,
+ xmlNode * node,
+ rra_def_t *rra_def)
+{
+ int status;
+
+ status = get_string_from_node(doc, node,
+ rra_def->cf_nam, sizeof(rra_def->cf_nam));
+ if (status != 0)
+ return (-1);
+
+ status = cf_conv(rra_def->cf_nam);
+ if (status == -1) {
+ rrd_set_error("parse_tag_rra_cf: Unknown consolidation function: %s",
+ rra_def->cf_nam);
+ return (-1);
+ }
+
+ return (0);
+} /* int parse_tag_rra_cf */
+
+static int parse_tag_rra(
+ xmlDoc * doc,
+ xmlNode * node,
+ rrd_t *rrd)
+{
+ xmlNode *child;
+ int status;
+
+ rra_def_t *cur_rra_def;
+ cdp_prep_t *cur_cdp_prep;
+ rra_ptr_t *cur_rra_ptr;
+
+ /* Allocate more rra_def space for this RRA */
+ { /* {{{ */
+ rra_def_t *temp;
+
+ temp = (rra_def_t *) realloc(rrd->rra_def,
+ sizeof(rra_def_t) *
+ (rrd->stat_head->rra_cnt + 1));
+ if (temp == NULL) {
+ rrd_set_error("parse_tag_rra: realloc failed.");
+ return (-1);