summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-08-07 11:28:29 +0300
committerGitHub <noreply@github.com>2020-08-07 11:28:29 +0300
commit5a718bb8b02eef930b41ef1f79873d93c2d38248 (patch)
tree1b808087300cf984134847431082517e1b49eb7f /daemon
parent49e417b33701037b82c17dca7731b41a6bed5869 (diff)
Stop multi-host DB statistics from being counted multiple times. (#9685)
Diffstat (limited to 'daemon')
-rw-r--r--daemon/global_statistics.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/daemon/global_statistics.c b/daemon/global_statistics.c
index e5aeb6e128..7e78355138 100644
--- a/daemon/global_statistics.c
+++ b/daemon/global_statistics.c
@@ -537,12 +537,17 @@ void global_statistics_charts(void) {
RRDHOST *host;
unsigned long long stats_array[RRDENG_NR_STATS] = {0};
unsigned long long local_stats_array[RRDENG_NR_STATS];
- unsigned hosts_with_dbengine = 0, i;
+ unsigned dbengine_contexts = 0, counted_multihost_db = 0, i;
rrd_rdlock();
rrdhost_foreach_read(host) {
- if (host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
- ++hosts_with_dbengine;
+ if (host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && !rrdhost_flag_check(host, RRDHOST_FLAG_ARCHIVED)) {
+ if (&multidb_ctx == host->rrdeng_ctx) {
+ if (counted_multihost_db)
+ continue; /* Only count multi-host DB once */
+ counted_multihost_db = 1;
+ }
+ ++dbengine_contexts;
/* get localhost's DB engine's statistics */
rrdeng_get_37_statistics(host->rrdeng_ctx, local_stats_array);
for (i = 0 ; i < RRDENG_NR_STATS ; ++i) {
@@ -553,8 +558,8 @@ void global_statistics_charts(void) {
}
rrd_unlock();
- if (hosts_with_dbengine) {
- /* deduplicate global statistics by getting the ones from the last host */
+ if (dbengine_contexts) {
+ /* deduplicate global statistics by getting the ones from the last context */
stats_array[30] = local_stats_array[30];
stats_array[31] = local_stats_array[31];
stats_array[32] = local_stats_array[32];