added backends debugging; #2017
Costa Tsaousis (ktsaou) committed
Mar 25, 2017 at 11:44 UTC
51fa67a4632506edd9278f679b55f173f13ba248
2 files changed
+32
-3
src/backends.c
+31
-3
@@ -570,29 +570,57 @@ void *backends_main(void *ptr) {
570
if(unlikely(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &pthreadoldcancelstate) != 0))
571
error("Cannot set pthread cancel state to DISABLE.");
572
573
+ size_t count_hosts = 0;
574
+ size_t count_charts_total = 0;
575
+ size_t count_dims_total = 0;
576
+
577
rrd_rdlock();
578
RRDHOST *host;
579
rrdhost_foreach_read(host) {
576
- if(host->rrd_memory_mode == RRD_MEMORY_MODE_NONE)
580
+ if(host->rrd_memory_mode == RRD_MEMORY_MODE_NONE) {
581
+ debug(D_BACKEND, "BACKEND: not sending host '%s' because its memory mode is '%s'", host->hostname, rrd_memory_mode_name(host->rrd_memory_mode));
582
continue;
583
+ }
584
585
rrdhost_rdlock(host);
586
587
+ count_hosts++;
588
+ size_t count_charts = 0;
589
+ size_t count_dims = 0;
590
+ size_t count_dims_skipped = 0;
591
+
592
+ const char *__hostname = (host == localhost)?hostname:host->hostname;
593
+
594
RRDSET *st;
595
rrdset_foreach_read(st, host) {
596
rrdset_rdlock(st);
597
598
+ count_charts++;
599
+
600
RRDDIM *rd;
601
rrddim_foreach_read(rd, st) {
587
- if(rd->last_collected_time.tv_sec >= after)
588
- chart_buffered_metrics += backend_request_formatter(b, prefix, host, (host == localhost)?hostname:host->hostname, st, rd, after, before, options);
602
+ if(likely(rd->last_collected_time.tv_sec >= after)) {
603
+ chart_buffered_metrics += backend_request_formatter(b, prefix, host, __hostname, st, rd, after, before, options);
604
+ count_dims++;
605
+ }
606
+ else {
607
+ debug(D_BACKEND, "BACKEND: not sending dimension '%s' of chart '%s' from host '%s', its last data collection is not within our timeframe", rd->id, st->id, __hostname);
608
+ count_dims_skipped++;
609
+ }
610
}
611
rrdset_unlock(st);
612
}
613
+
614
+ debug(D_BACKEND, "BACKEND: sending host '%s', metrics of %zu dimensions, of %zu charts. Skipped %zu dimensions.", __hostname, count_dims, count_charts, count_dims_skipped);
615
+ count_charts_total += count_charts;
616
+ count_dims_total += count_dims;
617
+
618
rrdhost_unlock(host);
619
}
620
rrd_unlock();
621
622
+ debug(D_BACKEND, "BACKEND: buffer has %zu bytes, added metrics for %zu dimensions, of %zu charts, from %zu hosts", buffer_strlen(b), count_dims_total, count_charts_total, count_hosts);
623
+
624
if(unlikely(pthread_setcancelstate(pthreadoldcancelstate, NULL) != 0))
625
error("Cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);
626
src/log.h
+1
@@ -28,6 +28,7 @@
28
#define D_CONNECT_TO 0x0000000001000000
29
#define D_RRDHOST 0x0000000002000000
30
#define D_LOCKS 0x0000000004000000
31
+#define D_BACKEND 0x0000000008000000
32
#define D_SYSTEM 0x8000000000000000
33
34
//#define DEBUG (D_WEB_CLIENT_ACCESS|D_LISTENER|D_RRD_STATS)