summaryrefslogtreecommitdiffstats
path: root/daemon/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/main.c')
-rw-r--r--daemon/main.c142
1 files changed, 114 insertions, 28 deletions
diff --git a/daemon/main.c b/daemon/main.c
index c18778974..e10d38b40 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -340,12 +340,12 @@ int help(int exitcode) {
" -W sqlite-compact Reclaim metadata database unused space and exit.\n\n"
#ifdef ENABLE_DBENGINE
" -W createdataset=N Create a DB engine dataset of N seconds and exit.\n\n"
- " -W stresstest=A,B,C,D,E,F\n"
+ " -W stresstest=A,B,C,D,E,F,G\n"
" Run a DB engine stress test for A seconds,\n"
" with B writers and C readers, with a ramp up\n"
" time of D seconds for writers, a page cache\n"
" size of E MiB, an optional disk space limit\n"
- " of F MiB and exit.\n\n"
+ " of F MiB, G libuv workers (default 16) and exit.\n\n"
#endif
" -W set section option value\n"
" set netdata.conf option from the command line.\n\n"
@@ -385,24 +385,24 @@ static void security_init(){
static void log_init(void) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/debug.log", netdata_configured_log_dir);
- stdout_filename = config_get(CONFIG_SECTION_GLOBAL, "debug log", filename);
+ stdout_filename = config_get(CONFIG_SECTION_LOGS, "debug", filename);
snprintfz(filename, FILENAME_MAX, "%s/error.log", netdata_configured_log_dir);
- stderr_filename = config_get(CONFIG_SECTION_GLOBAL, "error log", filename);
+ stderr_filename = config_get(CONFIG_SECTION_LOGS, "error", filename);
snprintfz(filename, FILENAME_MAX, "%s/access.log", netdata_configured_log_dir);
- stdaccess_filename = config_get(CONFIG_SECTION_GLOBAL, "access log", filename);
+ stdaccess_filename = config_get(CONFIG_SECTION_LOGS, "access", filename);
char deffacility[8];
snprintfz(deffacility,7,"%s","daemon");
- facility_log = config_get(CONFIG_SECTION_GLOBAL, "facility log", deffacility);
+ facility_log = config_get(CONFIG_SECTION_LOGS, "facility", deffacility);
- error_log_throttle_period = config_get_number(CONFIG_SECTION_GLOBAL, "errors flood protection period", error_log_throttle_period);
- error_log_errors_per_period = (unsigned long)config_get_number(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection", (long long int)error_log_errors_per_period);
+ error_log_throttle_period = config_get_number(CONFIG_SECTION_LOGS, "errors flood protection period", error_log_throttle_period);
+ error_log_errors_per_period = (unsigned long)config_get_number(CONFIG_SECTION_LOGS, "errors to trigger flood protection", (long long int)error_log_errors_per_period);
error_log_errors_per_period_backup = error_log_errors_per_period;
- setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get(CONFIG_SECTION_GLOBAL, "errors flood protection period" , ""), 1);
- setenv("NETDATA_ERRORS_PER_PERIOD", config_get(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection", ""), 1);
+ setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get(CONFIG_SECTION_LOGS, "errors flood protection period" , ""), 1);
+ setenv("NETDATA_ERRORS_PER_PERIOD", config_get(CONFIG_SECTION_LOGS, "errors to trigger flood protection", ""), 1);
}
char *initialize_lock_directory_path(char *prefix)
@@ -410,7 +410,7 @@ char *initialize_lock_directory_path(char *prefix)
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/lock", prefix);
- return config_get(CONFIG_SECTION_GLOBAL, "lock directory", filename);
+ return config_get(CONFIG_SECTION_DIRECTORIES, "lock", filename);
}
static void backwards_compatible_config() {
@@ -447,6 +447,75 @@ static void backwards_compatible_config() {
config_move(CONFIG_SECTION_GLOBAL, "web compression level",
CONFIG_SECTION_WEB, "gzip compression level");
+
+ config_move(CONFIG_SECTION_GLOBAL, "config directory",
+ CONFIG_SECTION_DIRECTORIES, "config");
+
+ config_move(CONFIG_SECTION_GLOBAL, "stock config directory",
+ CONFIG_SECTION_DIRECTORIES, "stock config");
+
+ config_move(CONFIG_SECTION_GLOBAL, "log directory",
+ CONFIG_SECTION_DIRECTORIES, "log");
+
+ config_move(CONFIG_SECTION_GLOBAL, "web files directory",
+ CONFIG_SECTION_DIRECTORIES, "web");
+
+ config_move(CONFIG_SECTION_GLOBAL, "cache directory",
+ CONFIG_SECTION_DIRECTORIES, "cache");
+
+ config_move(CONFIG_SECTION_GLOBAL, "lib directory",
+ CONFIG_SECTION_DIRECTORIES, "lib");
+
+ config_move(CONFIG_SECTION_GLOBAL, "home directory",
+ CONFIG_SECTION_DIRECTORIES, "home");
+
+ config_move(CONFIG_SECTION_GLOBAL, "lock directory",
+ CONFIG_SECTION_DIRECTORIES, "lock");
+
+ config_move(CONFIG_SECTION_GLOBAL, "plugins directory",
+ CONFIG_SECTION_DIRECTORIES, "plugins");
+
+ config_move(CONFIG_SECTION_HEALTH, "health configuration directory",
+ CONFIG_SECTION_DIRECTORIES, "health config");
+
+ config_move(CONFIG_SECTION_HEALTH, "stock health configuration directory",
+ CONFIG_SECTION_DIRECTORIES, "stock health config");
+
+ config_move(CONFIG_SECTION_REGISTRY, "registry db directory",
+ CONFIG_SECTION_DIRECTORIES, "registry");
+
+ config_move(CONFIG_SECTION_GLOBAL, "debug log",
+ CONFIG_SECTION_LOGS, "debug");
+
+ config_move(CONFIG_SECTION_GLOBAL, "error log",
+ CONFIG_SECTION_LOGS, "error");
+
+ config_move(CONFIG_SECTION_GLOBAL, "access log",
+ CONFIG_SECTION_LOGS, "access");
+
+ config_move(CONFIG_SECTION_GLOBAL, "facility log",
+ CONFIG_SECTION_LOGS, "facility");
+
+ config_move(CONFIG_SECTION_GLOBAL, "errors flood protection period",
+ CONFIG_SECTION_LOGS, "errors flood protection period");
+
+ config_move(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection",
+ CONFIG_SECTION_LOGS, "errors to trigger flood protection");
+
+ config_move(CONFIG_SECTION_GLOBAL, "debug flags",
+ CONFIG_SECTION_LOGS, "debug flags");
+
+ config_move(CONFIG_SECTION_GLOBAL, "TZ environment variable",
+ CONFIG_SECTION_ENV_VARS, "TZ");
+
+ config_move(CONFIG_SECTION_PLUGINS, "PATH environment variable",
+ CONFIG_SECTION_ENV_VARS, "PATH");
+
+ config_move(CONFIG_SECTION_PLUGINS, "PYTHONPATH environment variable",
+ CONFIG_SECTION_ENV_VARS, "PYTHONPATH");
+
+ config_move(CONFIG_SECTION_STATSD, "enabled",
+ CONFIG_SECTION_PLUGINS, "statsd");
}
static void get_netdata_configured_variables() {
@@ -491,14 +560,14 @@ static void get_netdata_configured_variables() {
// ------------------------------------------------------------------------
// get system paths
- netdata_configured_user_config_dir = config_get(CONFIG_SECTION_GLOBAL, "config directory", netdata_configured_user_config_dir);
- netdata_configured_stock_config_dir = config_get(CONFIG_SECTION_GLOBAL, "stock config directory", netdata_configured_stock_config_dir);
- netdata_configured_log_dir = config_get(CONFIG_SECTION_GLOBAL, "log directory", netdata_configured_log_dir);
- netdata_configured_web_dir = config_get(CONFIG_SECTION_GLOBAL, "web files directory", netdata_configured_web_dir);
- netdata_configured_cache_dir = config_get(CONFIG_SECTION_GLOBAL, "cache directory", netdata_configured_cache_dir);
- netdata_configured_varlib_dir = config_get(CONFIG_SECTION_GLOBAL, "lib directory", netdata_configured_varlib_dir);
+ netdata_configured_user_config_dir = config_get(CONFIG_SECTION_DIRECTORIES, "config", netdata_configured_user_config_dir);
+ netdata_configured_stock_config_dir = config_get(CONFIG_SECTION_DIRECTORIES, "stock config", netdata_configured_stock_config_dir);
+ netdata_configured_log_dir = config_get(CONFIG_SECTION_DIRECTORIES, "log", netdata_configured_log_dir);
+ netdata_configured_web_dir = config_get(CONFIG_SECTION_DIRECTORIES, "web", netdata_configured_web_dir);
+ netdata_configured_cache_dir = config_get(CONFIG_SECTION_DIRECTORIES, "cache", netdata_configured_cache_dir);
+ netdata_configured_varlib_dir = config_get(CONFIG_SECTION_DIRECTORIES, "lib", netdata_configured_varlib_dir);
char *env_home=getenv("HOME");
- netdata_configured_home_dir = config_get(CONFIG_SECTION_GLOBAL, "home directory", env_home?env_home:netdata_configured_home_dir);
+ netdata_configured_home_dir = config_get(CONFIG_SECTION_DIRECTORIES, "home", env_home?env_home:netdata_configured_home_dir);
netdata_configured_lock_dir = initialize_lock_directory_path(netdata_configured_varlib_dir);
@@ -554,6 +623,10 @@ static void get_netdata_configured_variables() {
#endif
// --------------------------------------------------------------------
+ // metric correlations
+ enable_metric_correlations = config_get_boolean(CONFIG_SECTION_GLOBAL, "enable metric correlations", enable_metric_correlations);
+
+ // --------------------------------------------------------------------
// get various system parameters
get_system_HZ();
@@ -563,7 +636,7 @@ static void get_netdata_configured_variables() {
}
-static int load_netdata_conf(char *filename, char overwrite_used) {
+int load_netdata_conf(char *filename, char overwrite_used) {
errno = 0;
int ret = 0;
@@ -773,17 +846,17 @@ int main(int argc, char **argv) {
char* stresstest_string = "stresstest=";
#endif
if(strcmp(optarg, "sqlite-check") == 0) {
- sql_init_database(DB_CHECK_INTEGRITY);
+ sql_init_database(DB_CHECK_INTEGRITY, 0);
return 0;
}
if(strcmp(optarg, "sqlite-fix") == 0) {
- sql_init_database(DB_CHECK_FIX_DB);
+ sql_init_database(DB_CHECK_FIX_DB, 0);
return 0;
}
if(strcmp(optarg, "sqlite-compact") == 0) {
- sql_init_database(DB_CHECK_RECLAIM_SPACE);
+ sql_init_database(DB_CHECK_RECLAIM_SPACE, 0);
return 0;
}
@@ -822,6 +895,9 @@ int main(int argc, char **argv) {
}
#endif
#ifdef ENABLE_DBENGINE
+ else if(strcmp(optarg, "dicttest") == 0) {
+ return dictionary_unittest(10000);
+ }
else if(strncmp(optarg, createdataset_string, strlen(createdataset_string)) == 0) {
optarg += strlen(createdataset_string);
unsigned history_seconds = strtoul(optarg, NULL, 0);
@@ -831,7 +907,7 @@ int main(int argc, char **argv) {
else if(strncmp(optarg, stresstest_string, strlen(stresstest_string)) == 0) {
char *endptr;
unsigned test_duration_sec = 0, dset_charts = 0, query_threads = 0, ramp_up_seconds = 0,
- page_cache_mb = 0, disk_space_mb = 0;
+ page_cache_mb = 0, disk_space_mb = 0, workers = 16;
optarg += strlen(stresstest_string);
test_duration_sec = (unsigned)strtoul(optarg, &endptr, 0);
@@ -845,7 +921,15 @@ int main(int argc, char **argv) {
page_cache_mb = (unsigned)strtoul(endptr + 1, &endptr, 0);
if (',' == *endptr)
disk_space_mb = (unsigned)strtoul(endptr + 1, &endptr, 0);
+ if (',' == *endptr)
+ workers = (unsigned)strtoul(endptr + 1, &endptr, 0);
+
+ if (workers > 1024)
+ workers = 1024;
+ char workers_str[16];
+ snprintf(workers_str, 15, "%u", workers);
+ setenv("UV_THREADPOOL_SIZE", workers_str, 1);
dbengine_stress_test(test_duration_sec, dset_charts, query_threads, ramp_up_seconds,
page_cache_mb, disk_space_mb);
return 0;
@@ -900,7 +984,7 @@ int main(int argc, char **argv) {
}
else if(strncmp(optarg, debug_flags_string, strlen(debug_flags_string)) == 0) {
optarg += strlen(debug_flags_string);
- config_set(CONFIG_SECTION_GLOBAL, "debug flags", optarg);
+ config_set(CONFIG_SECTION_LOGS, "debug flags", optarg);
debug_flags = strtoull(optarg, NULL, 0);
}
else if(strcmp(optarg, "set") == 0) {
@@ -1087,11 +1171,13 @@ int main(int argc, char **argv) {
if(i > 0)
mallopt(M_ARENA_MAX, 1);
#endif
- test_clock_boottime();
- test_clock_monotonic_coarse();
+
+ // initialize the system clocks
+ clocks_init();
// prepare configuration environment variables for the plugins
+ setenv("UV_THREADPOOL_SIZE", config_get(CONFIG_SECTION_GLOBAL, "libuv worker threads", "16"), 1);
get_netdata_configured_variables();
set_global_environment();
@@ -1109,7 +1195,7 @@ int main(int argc, char **argv) {
// --------------------------------------------------------------------
// get the debugging flags from the configuration file
- char *flags = config_get(CONFIG_SECTION_GLOBAL, "debug flags", "0x0000000000000000");
+ char *flags = config_get(CONFIG_SECTION_LOGS, "debug flags", "0x0000000000000000");
setenv("NETDATA_DEBUG_FLAGS", flags, 1);
debug_flags = strtoull(flags, NULL, 0);
@@ -1229,7 +1315,7 @@ int main(int argc, char **argv) {
// initialize rrd, registry, health, rrdpush, etc.
netdata_anonymous_statistics_enabled=-1;
- struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info));
+ struct rrdhost_system_info *system_info = callocz(1, sizeof(struct rrdhost_system_info));
get_system_info(system_info);
system_info->hops = 0;
get_install_type(&system_info->install_type, &system_info->prebuilt_arch, &system_info->prebuilt_dist);