@cryptotaxi247 / netdata-1 / commits / 48bdd9b51

load health config before creating localhost (#19689)

Costa Tsaousis committed Feb 21, 2025 at 13:35 UTC 48bdd9b51b90ddc98506561febb72e568e4a072c
4 files changed +17 -10
src/database/rrd.c
+7 -6
@@ -113,24 +113,25 @@ int rrd_init(const char *hostname, struct rrdhost_system_info *system_info, bool
113 }
114 }
115
116 - if(!unittest)
116 + if(!unittest) {
117 metadata_sync_init();
118 + health_load_config_defaults();
119 + }
120
121 localhost = rrdhost_create(
122 hostname
123 , registry_get_this_machine_hostname()
122 - , registry_get_this_machine_guid()
123 - , os_type
124 + , registry_get_this_machine_guid()
125 + , os_type
126 , netdata_configured_timezone
127 , netdata_configured_abbrev_timezone
128 , netdata_configured_utc_offset
129 , program_name
130 , NETDATA_VERSION
129 - ,
130 - nd_profile.update_every, default_rrd_history_entries
131 + , nd_profile.update_every, default_rrd_history_entries
132 , default_rrd_memory_mode
133 , health_plugin_enabled()
133 - , stream_send.enabled
134 + , stream_send.enabled
135 , stream_send.parents.destination
136 , stream_send.api_key
137 , stream_send.send_charts_matching
src/database/rrdhost.c
+3 -3
@@ -305,7 +305,7 @@ RRDHOST *rrdhost_create(
305 const char *prog_version,
306 int update_every,
307 long entries,
308 - RRD_DB_MODE memory_mode,
308 + RRD_DB_MODE memory_mode,
309 bool health,
310 bool stream,
311 STRING *parents,
@@ -349,8 +349,8 @@ RRDHOST *rrdhost_create(
349
350 rrdhost_init_hostname(host, hostname, false);
351
352 - host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
353 - host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? 0 : health;
352 + host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
353 + host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? false : health;
354
355 spinlock_init(&host->receiver_lock);
356
src/health/health.c
+5 -1
@@ -36,7 +36,11 @@ void health_plugin_disable(void) {
36 }
37
38
39 -static void health_load_config_defaults(void) {
39 +void health_load_config_defaults(void) {
40 + static bool done = false;
41 + if(done) return;
42 + done = true;
43 +
44 char filename[FILENAME_MAX + 1];
45
46 health_globals.config.enabled =
src/health/health.h
+2
@@ -103,4 +103,6 @@ uint64_t health_evloop_current_iteration(void);
103 void rrdhost_set_health_evloop_iteration(RRDHOST *host);
104 uint64_t rrdhost_health_evloop_last_iteration(RRDHOST *host);
105
106 +void health_load_config_defaults(void);
107 +
108 #endif //NETDATA_HEALTH_H