9 #define HOSTNAME_MAX 1024
10 char *hostname = "unknown";
12 unsigned long rrd_stats_one_json(RRDSET *st, char *options, struct web_buffer *wb)
14 time_t now = time(NULL);
15 web_buffer_increase(wb, 65536);
17 pthread_rwlock_rdlock(&st->rwlock);
21 "\t\t\t\"id\": \"%s\",\n"
22 "\t\t\t\"name\": \"%s\",\n"
23 "\t\t\t\"type\": \"%s\",\n"
24 "\t\t\t\"family\": \"%s\",\n"
25 "\t\t\t\"title\": \"%s\",\n"
26 "\t\t\t\"priority\": %ld,\n"
27 "\t\t\t\"enabled\": %d,\n"
28 "\t\t\t\"units\": \"%s\",\n"
29 "\t\t\t\"url\": \"/data/%s/%s\",\n"
30 "\t\t\t\"chart_type\": \"%s\",\n"
31 "\t\t\t\"counter\": %ld,\n"
32 "\t\t\t\"entries\": %ld,\n"
33 "\t\t\t\"first_entry_t\": %lu,\n"
34 "\t\t\t\"last_entry\": %ld,\n"
35 "\t\t\t\"last_entry_t\": %lu,\n"
36 "\t\t\t\"last_entry_secs_ago\": %lu,\n"
37 "\t\t\t\"update_every\": %d,\n"
38 "\t\t\t\"isdetail\": %d,\n"
39 "\t\t\t\"usec_since_last_update\": %llu,\n"
40 "\t\t\t\"collected_total\": " TOTAL_NUMBER_FORMAT ",\n"
41 "\t\t\t\"last_collected_total\": " TOTAL_NUMBER_FORMAT ",\n"
42 "\t\t\t\"dimensions\": [\n"
51 , st->name, options?options:""
52 , rrdset_type_name(st->chart_type)
55 , rrdset_first_entry_t(st)
56 , rrdset_last_slot(st)
57 , rrdset_last_entry_t(st)
58 , (now < rrdset_last_entry_t(st)) ? (time_t)0 : now - rrdset_last_entry_t(st)
61 , st->usec_since_last_update
63 , st->last_collected_total
66 unsigned long memory = st->memsize;
69 for(rd = st->dimensions; rd ; rd = rd->next) {
70 web_buffer_increase(wb, 4096);
72 memory += rd->memsize;
76 "\t\t\t\t\t\"id\": \"%s\",\n"
77 "\t\t\t\t\t\"name\": \"%s\",\n"
78 "\t\t\t\t\t\"entries\": %ld,\n"
79 "\t\t\t\t\t\"isHidden\": %d,\n"
80 "\t\t\t\t\t\"algorithm\": \"%s\",\n"
81 "\t\t\t\t\t\"multiplier\": %ld,\n"
82 "\t\t\t\t\t\"divisor\": %ld,\n"
83 "\t\t\t\t\t\"last_entry_t\": %lu,\n"
84 "\t\t\t\t\t\"collected_value\": " COLLECTED_NUMBER_FORMAT ",\n"
85 "\t\t\t\t\t\"calculated_value\": " CALCULATED_NUMBER_FORMAT ",\n"
86 "\t\t\t\t\t\"last_collected_value\": " COLLECTED_NUMBER_FORMAT ",\n"
87 "\t\t\t\t\t\"last_calculated_value\": " CALCULATED_NUMBER_FORMAT ",\n"
88 "\t\t\t\t\t\"memory\": %lu\n"
94 , rrddim_algorithm_name(rd->algorithm)
97 , rd->last_collected_time.tv_sec
99 , rd->calculated_value
100 , rd->last_collected_value
101 , rd->last_calculated_value
107 web_buffer_printf(wb,
109 "\t\t\t\"memory\" : %lu\n"
114 pthread_rwlock_unlock(&st->rwlock);
118 #define RRD_GRAPH_JSON_HEADER "{\n\t\"charts\": [\n"
119 #define RRD_GRAPH_JSON_FOOTER "\n\t]\n}\n"
121 void rrd_stats_graph_json(RRDSET *st, char *options, struct web_buffer *wb)
123 web_buffer_increase(wb, 2048);
125 web_buffer_printf(wb, RRD_GRAPH_JSON_HEADER);
126 rrd_stats_one_json(st, options, wb);
127 web_buffer_printf(wb, RRD_GRAPH_JSON_FOOTER);
130 void rrd_stats_all_json(struct web_buffer *wb)
132 web_buffer_increase(wb, 2048);
134 unsigned long memory = 0;
138 web_buffer_printf(wb, RRD_GRAPH_JSON_HEADER);
140 pthread_rwlock_rdlock(&rrdset_root_rwlock);
141 for(st = rrdset_root, c = 0; st ; st = st->next) {
143 if(c) web_buffer_printf(wb, "%s", ",\n");
144 memory += rrd_stats_one_json(st, NULL, wb);
148 pthread_rwlock_unlock(&rrdset_root_rwlock);
150 web_buffer_printf(wb, "\n\t],\n"
151 "\t\"hostname\": \"%s\",\n"
152 "\t\"update_every\": %d,\n"
153 "\t\"history\": %d,\n"
154 "\t\"memory\": %lu\n"
158 , rrd_default_history_entries
165 // ----------------------------------------------------------------------------
168 #define RRDR_EMPTY 0x01
169 #define RRDR_RESET 0x02
170 #define RRDR_HIDDEN 0x04
171 #define RRDR_NONZERO 0x08
174 typedef struct rrdresult {
175 RRDSET *st; // the chart this result refers to
177 int d; // the number of dimensions
178 int n; // the number of values in the arrays
180 uint8_t *od; // the options for the dimensions
182 time_t *t; // array of n timestamps
183 calculated_number *v; // array n x d values
184 uint8_t *o; // array n x d options
186 int c; // current line ( 0 ~ n )
188 int has_st_lock; // if st is read locked by us
191 static void rrdr_dump(RRDR *r)
196 fprintf(stderr, "\nCHART %s (%s)\n", r->st->id, r->st->name);
198 for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
199 fprintf(stderr, "DIMENSION %s (%s), %s%s%s%s\n"
202 , (r->od[c] & RRDR_EMPTY)?"EMPTY ":""
203 , (r->od[c] & RRDR_RESET)?"RESET ":""
204 , (r->od[c] & RRDR_HIDDEN)?"HIDDEN ":""
205 , (r->od[c] & RRDR_NONZERO)?"NONZERO ":""
210 fprintf(stderr, "RRDR does not have any values in it.\n");
214 fprintf(stderr, "RRDR includes %d values in it:\n", r->c + 1);
216 // for each line in the array
217 for(i = 0; i <= r->c ;i++) {
218 calculated_number *cn = &r->v[ i * r->d ];
219 uint8_t *co = &r->o[ i * r->d ];
221 // print the id and the timestamp of the line
222 fprintf(stderr, "%ld %ld ", i + 1, r->t[i]);
224 // for each dimension
225 for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
226 if(unlikely(r->od[c] & RRDR_HIDDEN)) continue;
227 if(unlikely(!(r->od[c] & RRDR_NONZERO))) continue;
229 if(co[c] & RRDR_EMPTY)
230 fprintf(stderr, "null ");
232 fprintf(stderr, CALCULATED_NUMBER_FORMAT " %s%s%s%s "
234 , (co[c] & RRDR_EMPTY)?"E":" "
235 , (co[c] & RRDR_RESET)?"R":" "
236 , (co[c] & RRDR_HIDDEN)?"H":" "
237 , (co[c] & RRDR_NONZERO)?"N":" "
241 fprintf(stderr, "\n");
245 inline static calculated_number *rrdr_line_values(RRDR *r)
247 return &r->v[ r->c * r->d ];
250 inline static uint8_t *rrdr_line_options(RRDR *r)
252 return &r->o[ r->c * r->d ];
255 inline static int rrdr_line_init(RRDR *r, time_t t)
258 if(unlikely(r->c >= r->n)) {
269 inline static void rrdr_lock_rrdset(RRDR *r) {
271 error("NULL value given!");
275 pthread_rwlock_rdlock(&r->st->rwlock);
279 inline static void rrdr_unlock_rrdset(RRDR *r) {
281 error("NULL value given!");
285 if(likely(r->has_st_lock)) {
286 pthread_rwlock_unlock(&r->st->rwlock);
291 inline static void rrdr_free(RRDR *r)
294 error("NULL value given!");
298 rrdr_unlock_rrdset(r);
299 if(likely(r->t)) free(r->t);
300 if(likely(r->v)) free(r->v);
301 if(likely(r->o)) free(r->o);
302 if(likely(r->od)) free(r->od);
306 static RRDR *rrdr_create(RRDSET *st, int n)
309 error("NULL value given!");
313 RRDR *r = calloc(1, sizeof(RRDR));
314 if(unlikely(!r)) goto cleanup;
321 for(rd = st->dimensions ; rd ; rd = rd->next) r->d++;
324 r->t = malloc(n * sizeof(time_t));
325 if(unlikely(!r->t)) goto cleanup;
327 r->t = malloc(n * sizeof(time_t));
328 if(unlikely(!r->t)) goto cleanup;
330 r->v = malloc(n * r->d * sizeof(calculated_number));
331 if(unlikely(!r->v)) goto cleanup;
333 r->o = malloc(n * r->d * sizeof(uint8_t));
334 if(unlikely(!r->o)) goto cleanup;
336 r->od = calloc(r->d, sizeof(uint8_t));
337 if(unlikely(!r->od)) goto cleanup;
344 error("Cannot allocate memory");
345 if(likely(r)) rrdr_free(r);
349 RRDR *rrd2rrdr(RRDSET *st, long points, time_t after, time_t before, int group_method)
351 int debug = st->debug;
353 time_t first_entry_t = rrdset_first_entry_t(st);
354 time_t last_entry_t = rrdset_last_entry_t(st);
356 // allow relative for before and after
357 if(before <= st->update_every * st->entries) before = last_entry_t + before;
358 if(after <= st->update_every * st->entries) after = last_entry_t + after;
360 // make sure they are within our timeframe
361 if(before > last_entry_t) before = last_entry_t;
362 if(before < first_entry_t) before = first_entry_t;
364 if(after > last_entry_t) after = last_entry_t;
365 if(after < first_entry_t) after = first_entry_t;
367 // check if they are upside down
374 // the duration of the chart
375 time_t duration = before - after;
376 if(duration <= 0) return NULL;
378 // check the required points
379 if(points <= 0) points = duration;
381 // calculate proper grouping of source data
382 long group = duration / points;
383 if(group <= 0) group = 1;
384 if(duration / group > points) group++;
386 // align timestamps to group
387 before -= before % group;
388 after -= after % group;
389 duration = before - after;
391 // error("NEW: points=%d after=%d before=%d group=%d, duration=%d", points, after, before, group, duration);
394 // before = the end time of the calculation
395 // after = the start time of the calculation
396 // duration = the duration of the calculation
397 // group = the number of source points to aggregate / group together
398 // method = the method of grouping source points
399 // points = the number of points to generate
402 // -------------------------------------------------------------------------
403 // initialize our result set
405 RRDR *r = rrdr_create(st, points);
412 // find how many dimensions we have
413 long dimensions = r->d;
416 // -------------------------------------------------------------------------
417 // checks for debugging
419 if(debug) debug(D_RRD_STATS, "INFO %s first_t: %lu, last_t: %lu, all_duration: %lu, after: %lu, before: %lu, duration: %lu, points: %ld, group: %ld"
423 , last_entry_t - first_entry_t
432 // -------------------------------------------------------------------------
433 // temp arrays for keeping values per dimension
435 calculated_number group_values[dimensions]; // keep sums when grouping
436 long group_counts[dimensions]; // keep the number of values added to group_values
437 uint8_t group_options[dimensions];
438 uint8_t found_non_zero[dimensions];
444 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
447 group_options[c] = 0;
448 found_non_zero[c] = 0;
452 // -------------------------------------------------------------------------
455 long t = rrdset_time2slot(st, before), // rrdset_last_slot(st),
456 stop_at_t = rrdset_time2slot(st, after),
462 time_t now = rrdset_slot2time(st, t),
463 dt = st->update_every,
466 if(debug) debug(D_RRD_STATS, "BEGIN %s after_t: %lu (stop slot %ld), before_t: %lu (start slot %ld), start_t(now): %lu"
475 for( ; !stop_now ; now -= dt, t--) {
476 if(unlikely(t < 0)) c = st->entries - 1;
477 if(t == stop_at_t) stop_now = 1;
479 if(debug) debug(D_RRD_STATS, "ROW %s c: %ld, group_count: %ld, added: %ld, now: %lu, %s %s"
485 , (group_count + 1 == group)?"PRINT":" - "
486 , (now >= after && now <= before)?"RANGE":" - "
489 // make sure we return data in the proper time range
490 if(unlikely(now > before)) continue;
491 if(unlikely(now < after)) break;
493 if(group_count == 0) group_start_t = now;
496 if(unlikely(group_count == group)) {
497 if(unlikely(added >= points)) break;
501 // do the calculations
502 for(rd = st->dimensions, c = 0 ; likely(rd && c < dimensions) ; rd = rd->next, c++) {
503 storage_number n = rd->values[t];
504 if(unlikely(!does_storage_number_exist(n))) continue;
508 calculated_number value = unpack_storage_number(n);
510 group_options[c] |= RRDR_NONZERO;
511 found_non_zero[c] = 1;
514 if(unlikely(did_storage_number_reset(n)))
515 group_options[c] |= RRDR_RESET;
517 switch(group_method) {
519 if(unlikely(abs(value) > abs(group_values[c])))
520 group_values[c] = value;
526 group_values[c] += value;
532 if(unlikely(add_this)) {
533 if(!rrdr_line_init(r, group_start_t)) break;
535 calculated_number *cn = rrdr_line_values(r);
536 uint8_t *co = rrdr_line_options(r);
538 for(rd = st->dimensions, c = 0 ; likely(rd && c < dimensions) ; rd = rd->next, c++) {
540 // update the dimension options
541 if(found_non_zero[c]) r->od[c] |= RRDR_NONZERO;
542 if(rd->hidden) r->od[c] |= RRDR_HIDDEN;
544 // store the specific point options
545 co[c] = group_options[c];
548 if(group_counts[c] == 0) {
552 else if(unlikely(group_method == GROUP_AVERAGE)) {
553 cn[c] = group_values[c] / group_counts[c];
556 cn[c] = group_values[c];
559 // reset them for the next loop
562 group_options[c] = 0;
576 unsigned long rrd_stats_json(int type, RRDSET *st, struct web_buffer *wb, int entries_to_show, int group, int group_method, time_t after, time_t before, int only_non_zero)
579 pthread_rwlock_rdlock(&st->rwlock);
582 // -------------------------------------------------------------------------
583 // switch from JSON to google JSON
588 case DATASOURCE_GOOGLE_JSON:
589 case DATASOURCE_GOOGLE_JSONP:
594 case DATASOURCE_JSON:
600 // -------------------------------------------------------------------------
601 // validate the parameters
603 if(entries_to_show < 1) entries_to_show = 1;
604 if(group < 1) group = 1;
606 time_t time_init = rrdset_last_entry_t(st);
608 if(before == 0 || before > time_init) before = time_init;
609 if(after == 0) after = rrdset_first_entry_t(st);
614 // our return value (the last timestamp printed)
615 // this is required to detect re-transmit in google JSONP
616 time_t last_timestamp = 0;
619 // -------------------------------------------------------------------------
620 // find how many dimensions we have
624 for( rd = st->dimensions ; rd ; rd = rd->next) dimensions++;
626 pthread_rwlock_unlock(&st->rwlock);
627 web_buffer_printf(wb, "No dimensions yet.");
632 // -------------------------------------------------------------------------
633 // prepare various strings, to speed up the loop
635 char overflow_annotation[201]; snprintf(overflow_annotation, 200, ",{%sv%s:%sRESET OR OVERFLOW%s},{%sv%s:%sThe counters have been wrapped.%s}", kq, kq, sq, sq, kq, kq, sq, sq);
636 char normal_annotation[201]; snprintf(normal_annotation, 200, ",{%sv%s:null},{%sv%s:null}", kq, kq, kq, kq);
637 char pre_date[51]; snprintf(pre_date, 50, " {%sc%s:[{%sv%s:%s", kq, kq, kq, kq, sq);
638 char post_date[21]; snprintf(post_date, 20, "%s}", sq);
639 char pre_value[21]; snprintf(pre_value, 20, ",{%sv%s:", kq, kq);
640 char post_value[21]; snprintf(post_value, 20, "}");
643 // -------------------------------------------------------------------------
644 // checks for debuging
647 debug(D_RRD_STATS, "%s first_entry_t = %lu, last_entry_t = %lu, duration = %lu, after = %lu, before = %lu, duration = %lu, entries_to_show = %lu, group = %lu"
649 , rrdset_first_entry_t(st)
650 , rrdset_last_entry_t(st)
651 , rrdset_last_entry_t(st) - rrdset_first_entry_t(st)
660 debug(D_RRD_STATS, "WARNING: %s The newest value in the database (%lu) is earlier than the oldest (%lu)", st->name, before, after);
662 if((before - after) > st->entries * st->update_every)
663 debug(D_RRD_STATS, "WARNING: %s The time difference between the oldest and the newest entries (%lu) is higher than the capacity of the database (%lu)", st->name, before - after, st->entries * st->update_every);
667 // -------------------------------------------------------------------------
668 // temp arrays for keeping values per dimension
670 calculated_number group_values[dimensions]; // keep sums when grouping
671 int print_hidden[dimensions]; // keep hidden flags
672 int found_non_zero[dimensions];
673 int found_non_existing[dimensions];
676 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
678 print_hidden[c] = rd->hidden;
679 found_non_zero[c] = 0;
680 found_non_existing[c] = 0;
684 // error("OLD: points=%d after=%d before=%d group=%d, duration=%d", entries_to_show, before - (st->update_every * group * entries_to_show), before, group, before - after + 1);
685 // rrd2array(st, entries_to_show, before - (st->update_every * group * entries_to_show), before, group_method, only_non_zero);
686 // rrd2rrdr(st, entries_to_show, before - (st->update_every * group * entries_to_show), before, group_method);
688 // -------------------------------------------------------------------------
689 // remove dimensions that contain only zeros
692 if(only_non_zero) max_loop = 2;
694 for(; max_loop ; max_loop--) {
696 // -------------------------------------------------------------------------
697 // print the JSON header
699 web_buffer_printf(wb, "{\n %scols%s:\n [\n", kq, kq);
700 web_buffer_printf(wb, " {%sid%s:%s%s,%slabel%s:%stime%s,%spattern%s:%s%s,%stype%s:%sdatetime%s},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq);
701 web_buffer_printf(wb, " {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotation%s}},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
702 web_buffer_printf(wb, " {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotationText%s}}", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
704 // print the header for each dimension
705 // and update the print_hidden array for the dimensions that should be hidden
707 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
708 if(!print_hidden[c]) {
710 web_buffer_printf(wb, ",\n {%sid%s:%s%s,%slabel%s:%s%s%s,%spattern%s:%s%s,%stype%s:%snumber%s}", kq, kq, sq, sq, kq, kq, sq, rd->name, sq, kq, kq, sq, sq, kq, kq, sq, sq);
714 web_buffer_printf(wb, ",\n {%sid%s:%s%s,%slabel%s:%s%s%s,%spattern%s:%s%s,%stype%s:%snumber%s}", kq, kq, sq, sq, kq, kq, sq, "no data", sq, kq, kq, sq, sq, kq, kq, sq, sq);
717 // print the begin of row data
718 web_buffer_printf(wb, "\n ],\n %srows%s:\n [\n", kq, kq);
721 // -------------------------------------------------------------------------
724 int annotate_reset = 0;
725 int annotation_count = 0;
727 // to allow grouping on the same values, we need a pad
728 long pad = before % group;
730 // the minimum line length we expect
731 int line_size = 4096 + (dimensions * 200);
733 time_t now = time_init;
735 long t = rrdset_time2slot(st, before),
736 stop_at_t = rrdset_time2slot(st, after),
739 long count = 0, printed = 0, group_count = 0;
742 for(; !stop_now ; now -= st->update_every, t--) {
743 if(t < 0) t = st->entries - 1;
744 if(t == stop_at_t) stop_now = 1;
749 debug(D_RRD_STATS, "%s t = %ld, count = %ld, group_count = %ld, printed = %ld, now = %lu, %s %s"
756 , (((count + 1 - pad) % group) == 0)?"PRINT":" - "
757 , (now >= after && now <= before)?"RANGE":" - "
761 // make sure we return data in the proper time range
762 if(now > before) continue;
763 if(now < after) break;
765 //if(rrdset_slot2time(st, t) != now)
766 // error("%s: slot=%ld, now=%ld, slot2time=%ld, diff=%ld, last_entry_t=%ld, rrdset_last_slot=%ld", st->id, t, now, rrdset_slot2time(st,t), now - rrdset_slot2time(st,t), rrdset_last_entry_t(st), rrdset_last_slot(st));
771 // check if we have to print this now
772 if(((count - pad) % group) == 0) {
773 if(printed >= entries_to_show) {
774 // debug(D_RRD_STATS, "Already printed all rows. Stopping.");
778 if(group_count != group) {
779 // this is an incomplete group, skip it.
780 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
782 found_non_existing[c] = 0;
789 // check if we may exceed the buffer provided
790 web_buffer_increase(wb, line_size);
792 // generate the local date time
793 struct tm *tm = localtime(&now);
794 if(!tm) { error("localtime() failed."); continue; }
795 if(now > last_timestamp) last_timestamp = now;
797 if(printed) web_buffer_strcpy(wb, "]},\n");
798 web_buffer_strcpy(wb, pre_date);
799 web_buffer_jsdate(wb, tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
800 web_buffer_strcpy(wb, post_date);
805 // do the calculations
806 for(rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
807 storage_number n = rd->values[t];
808 calculated_number value = unpack_storage_number(n);
810 if(!does_storage_number_exist(n)) {
812 found_non_existing[c]++;
814 if(did_storage_number_reset(n)) annotate_reset = 1;
816 switch(group_method) {
818 if(abs(value) > abs(group_values[c])) group_values[c] = value;
822 group_values[c] += value;
827 group_values[c] += value;
828 if(print_this) group_values[c] /= ( group_count - found_non_existing[c] );
836 web_buffer_strcpy(wb, overflow_annotation);
840 web_buffer_strcpy(wb, normal_annotation);
843 for(c = 0 ; c < dimensions ; c++) {
844 if(found_non_existing[c] == group_count) {
845 // all entries are non-existing
847 web_buffer_strcpy(wb, pre_value);
848 web_buffer_strcpy(wb, "null");
849 web_buffer_strcpy(wb, post_value);
851 else if(!print_hidden[c]) {
853 web_buffer_strcpy(wb, pre_value);
854 web_buffer_rrd_value(wb, group_values[c]);
855 web_buffer_strcpy(wb, post_value);
857 if(group_values[c]) found_non_zero[c]++;
860 // reset them for the next loop
862 found_non_existing[c] = 0;
865 // if all dimensions are hidden, print a null
867 web_buffer_strcpy(wb, pre_value);
868 web_buffer_strcpy(wb, "null");
869 web_buffer_strcpy(wb, post_value);
877 if(printed) web_buffer_printf(wb, "]}");
878 web_buffer_printf(wb, "\n ]\n}\n");
880 if(only_non_zero && max_loop > 1) {
882 for(rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
884 found_non_existing[c] = 0;
886 if(!print_hidden[c] && !found_non_zero[c]) {
892 if(changed) web_buffer_reset(wb);
899 debug(D_RRD_STATS, "RRD_STATS_JSON: %s total %ld bytes", st->name, wb->bytes);
901 pthread_rwlock_unlock(&st->rwlock);
902 return last_timestamp;