Browse Source

load health config before creating localhost (#19689)

Costa Tsaousis 2 weeks ago
parent
commit
48bdd9b51b
4 changed files with 17 additions and 10 deletions
  1. 7 6
      src/database/rrd.c
  2. 3 3
      src/database/rrdhost.c
  3. 5 1
      src/health/health.c
  4. 2 0
      src/health/health.h

+ 7 - 6
src/database/rrd.c

@@ -113,24 +113,25 @@ int rrd_init(const char *hostname, struct rrdhost_system_info *system_info, bool
         }
         }
     }
     }
 
 
-    if(!unittest)
+    if(!unittest) {
         metadata_sync_init();
         metadata_sync_init();
+        health_load_config_defaults();
+    }
 
 
     localhost = rrdhost_create(
     localhost = rrdhost_create(
         hostname
         hostname
         , registry_get_this_machine_hostname()
         , registry_get_this_machine_hostname()
-            , registry_get_this_machine_guid()
-            , os_type
+        , registry_get_this_machine_guid()
+        , os_type
         , netdata_configured_timezone
         , netdata_configured_timezone
         , netdata_configured_abbrev_timezone
         , netdata_configured_abbrev_timezone
         , netdata_configured_utc_offset
         , netdata_configured_utc_offset
         , program_name
         , program_name
         , NETDATA_VERSION
         , NETDATA_VERSION
-        ,
-        nd_profile.update_every, default_rrd_history_entries
+        , nd_profile.update_every, default_rrd_history_entries
         , default_rrd_memory_mode
         , default_rrd_memory_mode
         , health_plugin_enabled()
         , health_plugin_enabled()
-            , stream_send.enabled
+        , stream_send.enabled
         , stream_send.parents.destination
         , stream_send.parents.destination
         , stream_send.api_key
         , stream_send.api_key
         , stream_send.send_charts_matching
         , stream_send.send_charts_matching

+ 3 - 3
src/database/rrdhost.c

@@ -305,7 +305,7 @@ RRDHOST *rrdhost_create(
         const char *prog_version,
         const char *prog_version,
         int update_every,
         int update_every,
         long entries,
         long entries,
-    RRD_DB_MODE memory_mode,
+        RRD_DB_MODE memory_mode,
         bool health,
         bool health,
         bool stream,
         bool stream,
         STRING *parents,
         STRING *parents,
@@ -349,8 +349,8 @@ RRDHOST *rrdhost_create(
 
 
     rrdhost_init_hostname(host, hostname, false);
     rrdhost_init_hostname(host, hostname, false);
 
 
-    host->rrd_history_entries        = align_entries_to_pagesize(memory_mode, entries);
-    host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? 0 : health;
+    host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
+    host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? false : health;
 
 
     spinlock_init(&host->receiver_lock);
     spinlock_init(&host->receiver_lock);
 
 

+ 5 - 1
src/health/health.c

@@ -36,7 +36,11 @@ void health_plugin_disable(void) {
 }
 }
 
 
 
 
-static void health_load_config_defaults(void) {
+void health_load_config_defaults(void) {
+    static bool done = false;
+    if(done) return;
+    done = true;
+
     char filename[FILENAME_MAX + 1];
     char filename[FILENAME_MAX + 1];
 
 
     health_globals.config.enabled =
     health_globals.config.enabled =

+ 2 - 0
src/health/health.h

@@ -103,4 +103,6 @@ uint64_t health_evloop_current_iteration(void);
 void rrdhost_set_health_evloop_iteration(RRDHOST *host);
 void rrdhost_set_health_evloop_iteration(RRDHOST *host);
 uint64_t rrdhost_health_evloop_last_iteration(RRDHOST *host);
 uint64_t rrdhost_health_evloop_last_iteration(RRDHOST *host);
 
 
+void health_load_config_defaults(void);
+
 #endif //NETDATA_HEALTH_H
 #endif //NETDATA_HEALTH_H