From f55ccbfd21ef816c7958081f56f8f0d682251448 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Wed, 23 Oct 2013 19:06:58 +0200 Subject: [PATCH] argument parser regression fix - if no explicit reduce function is set, use the one associated with the RRA and not AVERAGE --- src/rrd_graph.c | 4 +++- src/rrd_graph.h | 1 + src/rrd_graph_helper.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index d2049a95..12033e6d 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -941,7 +941,8 @@ int data_fetch( chart and visibility of data will be random */ im->gdes[i].step = max(im->gdes[i].step,im->step); if (ft_step < im->gdes[i].step) { - reduce_data(im->gdes[i].cf_reduce, + + reduce_data(im->gdes[i].cf_reduce_set ? im->gdes[i].cf_reduce : im->gdes[i].cf, ft_step, &im->gdes[i].start, &im->gdes[i].end, @@ -4035,6 +4036,7 @@ int gdes_alloc( im->gdes[im->gdes_c - 1].rrd[0] = '\0'; im->gdes[im->gdes_c - 1].ds = -1; im->gdes[im->gdes_c - 1].cf_reduce = CF_AVERAGE; + im->gdes[im->gdes_c - 1].cf_reduce_set = 0; im->gdes[im->gdes_c - 1].cf = CF_AVERAGE; im->gdes[im->gdes_c - 1].yrule = DNAN; im->gdes[im->gdes_c - 1].xrule = 0; diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 18718bae..eca79e2e 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -207,6 +207,7 @@ typedef struct graph_desc_t { char daemon[256]; enum cf_en cf; /* consolidation function */ enum cf_en cf_reduce; /* consolidation function for reduce_data() */ + int cf_reduce_set; /* is the cf_reduce option set */ struct gfx_color_t col, col2; /* graph color */ double gradheight; char format[FMT_LEG_LEN + 5]; /* format for PRINT AND GPRINT */ diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 6be6f8e7..cb4ac9c9 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -470,6 +470,7 @@ static graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,pa char *reduce=getKeyValueArgument("reduce",1,pa); if (reduce) { gdp->cf_reduce=cf_conv(reduce); + gdp->cf_reduce_set=1; dprintfparsed("got reduce: %s (%i)\n",reduce,gdp->cf_reduce); if (((int)gdp->cf_reduce)==-1) { rrd_set_error("bad reduce CF: %s",reduce); return NULL; } } @@ -867,7 +868,7 @@ int parse_def(enum gf_en gf,parsedargs_t*pa,image_desc_t *const im){ ); if (gdp->step == 0){ gdp->step = im->step; /* initialize with image wide step */ - } + } if (!gdp) { return 1;} /* debugging output */ dprintf("=================================\n"); -- 2.47.3