@cryptotaxi247 / netdata-1 / commits / 70f277088

proper fix: nonzero option should return all selected dimensions if they are all zero; fixes #1658; fixes #1514

Costa Tsaousis (ktsaou) committed Jan 28, 2017 at 03:25 UTC 70f277088184231872a6ade236ae3fb5eb9f3e7f
2 files changed +6 -7
src/rrd2json.c
+6 -6
@@ -449,6 +449,7 @@ void rrd_stats_all_json(BUFFER *wb)
449 #define RRDR_RESET 0x02 // the dimension contains / the value is reset
450 #define RRDR_HIDDEN 0x04 // the dimension contains / the value is hidden
451 #define RRDR_NONZERO 0x08 // the dimension contains / the value is non-zero
452 +#define RRDR_SELECTED 0x10 // the dimension is selected
453
454 // RRDR result options
455 #define RRDR_RESULT_OPTION_ABSOLUTE 0x00000001
@@ -564,13 +565,12 @@ void rrdr_disable_not_selected_dimensions(RRDR *r, uint32_t options, const char
565 // find it and enable it
566 for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
567 if(unlikely((hash == d->hash && !strcmp(d->id, tok)) || !strcmp(d->name, tok))) {
567 - dims_selected++;
568
569 - r->od[c] |= RRDR_OPTION_SELECTED;
570 -
571 - // remove the hidden flag, if it is set
572 - if(likely(r->od[c] & RRDR_HIDDEN))
569 + if(likely(r->od[c] & RRDR_HIDDEN)) {
570 + r->od[c] |= RRDR_SELECTED;
571 r->od[c] &= ~RRDR_HIDDEN;
572 + dims_selected++;
573 + }
574
575 // since the user needs this dimension
576 // make it appear as NONZERO, to return it
@@ -593,7 +593,7 @@ void rrdr_disable_not_selected_dimensions(RRDR *r, uint32_t options, const char
593 // enable the selected ones
594 // to avoid returning an empty chart
595 for(c = 0, d = r->st->dimensions; d ;c++, d = d->next)
596 - if(unlikely(r->od[c] & RRDR_OPTION_SELECTED))
596 + if(unlikely(r->od[c] & RRDR_SELECTED))
597 r->od[c] |= RRDR_NONZERO;
598 }
599 }
src/rrd2json.h
-1
@@ -57,7 +57,6 @@
57 #define RRDR_OPTION_LABEL_QUOTES 0x00000400 // in CSV output, wrap header labels in double quotes
58 #define RRDR_OPTION_PERCENTAGE 0x00000800 // give values as percentage of total
59 #define RRDR_OPTION_NOT_ALIGNED 0x00001000 // do not align charts for persistant timeframes
60 -#define RRDR_OPTION_SELECTED 0x00002000 // the dimension is selected by the caller: rrdr_disable_not_selected_dimensions()
60
61 extern void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb);
62 extern void rrd_stats_api_v1_charts(BUFFER *wb);