mirror of
https://github.com/netdata/netdata.git
synced 2025-04-29 07:00:01 +00:00
Clean host structure (#14584)
* Remove varlib_dir from host structure * Remove unused parameter
This commit is contained in:
parent
56f522ad1c
commit
37ba7d615d
3 changed files with 4 additions and 25 deletions
|
@ -997,7 +997,6 @@ struct rrdhost {
|
||||||
// the actual per tier is at .db[tier].mode
|
// the actual per tier is at .db[tier].mode
|
||||||
|
|
||||||
char *cache_dir; // the directory to save RRD cache files
|
char *cache_dir; // the directory to save RRD cache files
|
||||||
char *varlib_dir; // the directory to save health log
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
RRD_MEMORY_MODE mode; // the db mode for this tier
|
RRD_MEMORY_MODE mode; // the db mode for this tier
|
||||||
|
|
|
@ -333,10 +333,8 @@ int is_legacy = 1;
|
||||||
rrdhost_option_set(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST);
|
rrdhost_option_set(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST);
|
||||||
|
|
||||||
char filename[FILENAME_MAX + 1];
|
char filename[FILENAME_MAX + 1];
|
||||||
if(is_localhost) {
|
if(is_localhost)
|
||||||
host->cache_dir = strdupz(netdata_configured_cache_dir);
|
host->cache_dir = strdupz(netdata_configured_cache_dir);
|
||||||
host->varlib_dir = strdupz(netdata_configured_varlib_dir);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// this is not localhost - append our GUID to localhost path
|
// this is not localhost - append our GUID to localhost path
|
||||||
if (is_in_multihost) { // don't append to cache dir in multihost
|
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)
|
if(r != 0 && errno != EEXIST)
|
||||||
error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->cache_dir);
|
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
|
// 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')"
|
" (to '%s' with api key '%s')"
|
||||||
", health %s"
|
", health %s"
|
||||||
", cache_dir '%s'"
|
", cache_dir '%s'"
|
||||||
", varlib_dir '%s'"
|
|
||||||
", alarms default handler '%s'"
|
", alarms default handler '%s'"
|
||||||
", alarms default recipient '%s'"
|
", alarms default recipient '%s'"
|
||||||
, rrdhost_hostname(host)
|
, rrdhost_hostname(host)
|
||||||
|
@ -521,7 +515,6 @@ int is_legacy = 1;
|
||||||
, host->rrdpush_send_api_key?host->rrdpush_send_api_key:""
|
, host->rrdpush_send_api_key?host->rrdpush_send_api_key:""
|
||||||
, host->health.health_enabled?"enabled":"disabled"
|
, host->health.health_enabled?"enabled":"disabled"
|
||||||
, host->cache_dir
|
, host->cache_dir
|
||||||
, host->varlib_dir
|
|
||||||
, string2str(host->health.health_default_exec)
|
, string2str(host->health.health_default_exec)
|
||||||
, string2str(host->health.health_default_recipient)
|
, 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);
|
string_freez(host->program_version);
|
||||||
rrdhost_system_info_free(host->system_info);
|
rrdhost_system_info_free(host->system_info);
|
||||||
freez(host->cache_dir);
|
freez(host->cache_dir);
|
||||||
freez(host->varlib_dir);
|
|
||||||
freez(host->rrdpush_send_api_key);
|
freez(host->rrdpush_send_api_key);
|
||||||
freez(host->rrdpush_send_destination);
|
freez(host->rrdpush_send_destination);
|
||||||
rrdpush_destinations_free(host);
|
rrdpush_destinations_free(host);
|
||||||
|
|
|
@ -753,7 +753,8 @@ static void health_main_cleanup(void *ptr) {
|
||||||
log_health("Health thread ended.");
|
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 ||
|
if(!host->health.health_enabled ||
|
||||||
rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH) ||
|
rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH) ||
|
||||||
!service_running(SERVICE_HEALTH))
|
!service_running(SERVICE_HEALTH))
|
||||||
|
@ -786,19 +787,6 @@ static void initialize_health(RRDHOST *host, int is_localhost) {
|
||||||
|
|
||||||
char filename[FILENAME_MAX + 1];
|
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);
|
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_exec = string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
|
||||||
host->health.health_default_recipient = string_strdupz("root");
|
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))) {
|
if (unlikely(!rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH))) {
|
||||||
rrd_unlock();
|
rrd_unlock();
|
||||||
initialize_health(host, host == localhost);
|
initialize_health(host);
|
||||||
rrd_rdlock();
|
rrd_rdlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue