0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 06:32:30 +00:00

Clean host structure ()

* Remove varlib_dir from host structure

* Remove unused parameter
This commit is contained in:
Stelios Fragkakis 2023-02-22 20:58:29 +02:00 committed by GitHub
parent 56f522ad1c
commit 37ba7d615d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 25 deletions

View file

@ -997,7 +997,6 @@ struct rrdhost {
// the actual per tier is at .db[tier].mode
char *cache_dir; // the directory to save RRD cache files
char *varlib_dir; // the directory to save health log
struct {
RRD_MEMORY_MODE mode; // the db mode for this tier

View file

@ -333,10 +333,8 @@ int is_legacy = 1;
rrdhost_option_set(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST);
char filename[FILENAME_MAX + 1];
if(is_localhost) {
if(is_localhost)
host->cache_dir = strdupz(netdata_configured_cache_dir);
host->varlib_dir = strdupz(netdata_configured_varlib_dir);
}
else {
// this is not localhost - append our GUID to localhost path
if (is_in_multihost) { // don't append to cache dir in multihost
@ -353,9 +351,6 @@ int is_legacy = 1;
if(r != 0 && errno != EEXIST)
error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->cache_dir);
}
snprintfz(filename, FILENAME_MAX, "%s/%s", netdata_configured_varlib_dir, host->machine_guid);
host->varlib_dir = strdupz(filename);
}
// this is also needed for custom host variables - not only health
@ -502,7 +497,6 @@ int is_legacy = 1;
" (to '%s' with api key '%s')"
", health %s"
", cache_dir '%s'"
", varlib_dir '%s'"
", alarms default handler '%s'"
", alarms default recipient '%s'"
, rrdhost_hostname(host)
@ -521,7 +515,6 @@ int is_legacy = 1;
, host->rrdpush_send_api_key?host->rrdpush_send_api_key:""
, host->health.health_enabled?"enabled":"disabled"
, host->cache_dir
, host->varlib_dir
, string2str(host->health.health_default_exec)
, string2str(host->health.health_default_recipient)
);
@ -1204,7 +1197,6 @@ void rrdhost_free___while_having_rrd_wrlock(RRDHOST *host, bool force) {
string_freez(host->program_version);
rrdhost_system_info_free(host->system_info);
freez(host->cache_dir);
freez(host->varlib_dir);
freez(host->rrdpush_send_api_key);
freez(host->rrdpush_send_destination);
rrdpush_destinations_free(host);

View file

@ -753,7 +753,8 @@ static void health_main_cleanup(void *ptr) {
log_health("Health thread ended.");
}
static void initialize_health(RRDHOST *host, int is_localhost) {
static void initialize_health(RRDHOST *host)
{
if(!host->health.health_enabled ||
rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH) ||
!service_running(SERVICE_HEALTH))
@ -786,19 +787,6 @@ static void initialize_health(RRDHOST *host, int is_localhost) {
char filename[FILENAME_MAX + 1];
if(!is_localhost) {
int r = mkdir(host->varlib_dir, 0775);
if (r != 0 && errno != EEXIST)
error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->varlib_dir);
}
{
snprintfz(filename, FILENAME_MAX, "%s/health", host->varlib_dir);
int r = mkdir(filename, 0775);
if(r != 0 && errno != EEXIST)
error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), filename);
}
snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_primary_plugins_dir);
host->health.health_default_exec = string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
host->health.health_default_recipient = string_strdupz("root");
@ -1039,7 +1027,7 @@ void *health_main(void *ptr) {
if (unlikely(!rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH))) {
rrd_unlock();
initialize_health(host, host == localhost);
initialize_health(host);
rrd_rdlock();
}