Clean host structure (#14584)
* Remove varlib_dir from host structure * Remove unused parameter
Stelios Fragkakis committed
Feb 22, 2023 at 20:58 UTC
37ba7d615d458a5246a93e8ad0e67294500d538c
3 files changed
+4
-25
database/rrd.h
-1
@@ -997,7 +997,6 @@ struct rrdhost {
997
// the actual per tier is at .db[tier].mode
998
999
char *cache_dir; // the directory to save RRD cache files
1000
- char *varlib_dir; // the directory to save health log
1000
1001
struct {
1002
RRD_MEMORY_MODE mode; // the db mode for this tier
database/rrdhost.c
+1
-9
@@ -333,10 +333,8 @@ int is_legacy = 1;
333
rrdhost_option_set(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST);
334
335
char filename[FILENAME_MAX + 1];
336
- if(is_localhost) {
336
+ if(is_localhost)
337
host->cache_dir = strdupz(netdata_configured_cache_dir);
338
- host->varlib_dir = strdupz(netdata_configured_varlib_dir);
339
- }
338
else {
339
// this is not localhost - append our GUID to localhost path
340
if (is_in_multihost) { // don't append to cache dir in multihost
@@ -353,9 +351,6 @@ int is_legacy = 1;
351
if(r != 0 && errno != EEXIST)
352
error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->cache_dir);
353
}
356
-
357
- snprintfz(filename, FILENAME_MAX, "%s/%s", netdata_configured_varlib_dir, host->machine_guid);
358
- host->varlib_dir = strdupz(filename);
354
}
355
356
// this is also needed for custom host variables - not only health
@@ -502,7 +497,6 @@ int is_legacy = 1;
497
" (to '%s' with api key '%s')"
498
", health %s"
499
", cache_dir '%s'"
505
- ", varlib_dir '%s'"
500
", alarms default handler '%s'"
501
", alarms default recipient '%s'"
502
, rrdhost_hostname(host)
@@ -521,7 +515,6 @@ int is_legacy = 1;
515
, host->rrdpush_send_api_key?host->rrdpush_send_api_key:""
516
, host->health.health_enabled?"enabled":"disabled"
517
, host->cache_dir
524
- , host->varlib_dir
518
, string2str(host->health.health_default_exec)
519
, string2str(host->health.health_default_recipient)
520
);
@@ -1204,7 +1197,6 @@ void rrdhost_free___while_having_rrd_wrlock(RRDHOST *host, bool force) {
1197
string_freez(host->program_version);
1198
rrdhost_system_info_free(host->system_info);
1199
freez(host->cache_dir);
1207
- freez(host->varlib_dir);
1200
freez(host->rrdpush_send_api_key);
1201
freez(host->rrdpush_send_destination);
1202
rrdpush_destinations_free(host);
health/health.c
+3
-15
@@ -753,7 +753,8 @@ static void health_main_cleanup(void *ptr) {
753
log_health("Health thread ended.");
754
}
755
756
-static void initialize_health(RRDHOST *host, int is_localhost) {
756
+static void initialize_health(RRDHOST *host)
757
+{
758
if(!host->health.health_enabled ||
759
rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH) ||
760
!service_running(SERVICE_HEALTH))
@@ -786,19 +787,6 @@ static void initialize_health(RRDHOST *host, int is_localhost) {
787
788
char filename[FILENAME_MAX + 1];
789
789
- if(!is_localhost) {
790
- int r = mkdir(host->varlib_dir, 0775);
791
- if (r != 0 && errno != EEXIST)
792
- error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->varlib_dir);
793
- }
794
-
795
- {
796
- snprintfz(filename, FILENAME_MAX, "%s/health", host->varlib_dir);
797
- int r = mkdir(filename, 0775);
798
- if(r != 0 && errno != EEXIST)
799
- error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), filename);
800
- }
801
-
790
snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_primary_plugins_dir);
791
host->health.health_default_exec = string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
792
host->health.health_default_recipient = string_strdupz("root");
@@ -1039,7 +1027,7 @@ void *health_main(void *ptr) {
1027
1028
if (unlikely(!rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH))) {
1029
rrd_unlock();
1042
- initialize_health(host, host == localhost);
1030
+ initialize_health(host);
1031
rrd_rdlock();
1032
}
1033