From 758d9c405d2d768a3c125052a02c7a1503b01bd8 Mon Sep 17 00:00:00 2001 From: Costa Tsaousis Date: Sun, 9 Oct 2022 21:58:21 +0300 Subject: full memory tracking and profiling of Netdata Agent (#13789) * full memory tracking and profiling of Netdata Agent * initialize dbengine only when it is needed * handling of dbengine compiled but not available * restore unittest * restore unittest again * more improvements about ifdef dbengine * fix compilation when dbengine is not enabled * check if dbengine is enabled on exit * call freez() not free() * aral unittest * internal checks activate trace allocations; dev mode activates internal checks --- streaming/receiver.c | 9 +++------ streaming/rrdpush.c | 25 +++++++++++++++++++++++++ streaming/rrdpush.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) (limited to 'streaming') diff --git a/streaming/receiver.c b/streaming/receiver.c index 6890f8b2d9..02aa040b06 100644 --- a/streaming/receiver.c +++ b/streaming/receiver.c @@ -487,13 +487,10 @@ static int rrdpush_receive(struct receiver_state *rpt) mode = rrd_memory_mode_id(appconfig_get(&stream_config, rpt->key, "default memory mode", rrd_memory_mode_name(mode))); mode = rrd_memory_mode_id(appconfig_get(&stream_config, rpt->machine_guid, "memory mode", rrd_memory_mode_name(mode))); -#ifndef ENABLE_DBENGINE - if (unlikely(mode == RRD_MEMORY_MODE_DBENGINE)) { - close(rpt->fd); - log_stream_connection(rpt->client_ip, rpt->client_port, rpt->key, rpt->machine_guid, rpt->hostname, "REJECTED -- DBENGINE MEMORY MODE NOT SUPPORTED"); - return 1; + if (unlikely(mode == RRD_MEMORY_MODE_DBENGINE && !dbengine_enabled)) { + error("STREAM %s [receive from %s:%s]: dbengine is not enabled, falling back to default.", rpt->hostname, rpt->client_ip, rpt->client_port); + mode = default_rrd_memory_mode; } -#endif health_enabled = appconfig_get_boolean_ondemand(&stream_config, rpt->key, "health enabled by default", health_enabled); health_enabled = appconfig_get_boolean_ondemand(&stream_config, rpt->machine_guid, "health enabled", health_enabled); diff --git a/streaming/rrdpush.c b/streaming/rrdpush.c index 018b29a033..c332b3bcd3 100644 --- a/streaming/rrdpush.c +++ b/streaming/rrdpush.c @@ -66,6 +66,31 @@ static void load_stream_conf() { freez(filename); } +bool rrdpush_receiver_needs_dbengine() { + struct section *co; + + for(co = stream_config.first_section; co; co = co->next) { + if(strcmp(co->name, "stream") == 0) + continue; // the first section is not relevant + + char *s; + + s = appconfig_get_by_section(co, "enabled", NULL); + if(!s || !appconfig_test_boolean_value(s)) + continue; + + s = appconfig_get_by_section(co, "default memory mode", NULL); + if(s && strcmp(s, "dbengine") == 0) + return true; + + s = appconfig_get_by_section(co, "memory mode", NULL); + if(s && strcmp(s, "dbengine") == 0) + return true; + } + + return false; +} + int rrdpush_init() { // -------------------------------------------------------------------- // load stream.conf diff --git a/streaming/rrdpush.h b/streaming/rrdpush.h index 22ce7f3f16..c6cd79fab8 100644 --- a/streaming/rrdpush.h +++ b/streaming/rrdpush.h @@ -228,6 +228,7 @@ BUFFER *sender_start(struct sender_state *s); void sender_commit(struct sender_state *s, BUFFER *wb); void sender_cancel(struct sender_state *s); int rrdpush_init(); +bool rrdpush_receiver_needs_dbengine(); int configured_as_parent(); void rrdset_done_push(RRDSET *st); bool rrdset_push_chart_definition_now(RRDSET *st); -- cgit v1.2.3