summaryrefslogtreecommitdiffstats
path: root/daemon/main.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
commite970e0b37b8bd7f246feb3f70c4136418225e434 (patch)
tree0b67c0ca45f56f2f9d9c5c2e725279ecdf52d2eb /daemon/main.c
parentAdding upstream version 1.31.0. (diff)
downloadnetdata-e970e0b37b8bd7f246feb3f70c4136418225e434.tar.xz
netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.zip
Adding upstream version 1.32.0.upstream/1.32.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/main.c')
-rw-r--r--daemon/main.c94
1 files changed, 43 insertions, 51 deletions
diff --git a/daemon/main.c b/daemon/main.c
index 61041f540..2ec5c33f9 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -28,7 +28,6 @@ void netdata_cleanup_and_exit(int ret) {
info("EXIT: netdata prepares to exit with code %d...", ret);
send_statistics("EXIT", ret?"ERROR":"OK","-");
- analytics_free_data();
char agent_crash_file[FILENAME_MAX + 1];
char agent_incomplete_shutdown_file[FILENAME_MAX + 1];
@@ -45,6 +44,9 @@ void netdata_cleanup_and_exit(int ret) {
// stop everything
info("EXIT: stopping static threads...");
+#ifdef ENABLE_NEW_CLOUD_PROTOCOL
+ aclk_sync_exit_all();
+#endif
cancel_main_threads();
// free the database
@@ -104,6 +106,7 @@ struct netdata_static_thread static_threads[] = {
NETDATA_PLUGIN_HOOK_PLUGINSD
NETDATA_PLUGIN_HOOK_HEALTH
NETDATA_PLUGIN_HOOK_ANALYTICS
+ NETDATA_PLUGIN_HOOK_SERVICE
{NULL, NULL, NULL, 0, NULL, NULL, NULL}
};
@@ -360,13 +363,16 @@ int help(int exitcode) {
" -W stacksize=N Set the stacksize (in bytes).\n\n"
" -W debug_flags=N Set runtime tracing to debug.log.\n\n"
" -W unittest Run internal unittests and exit.\n\n"
+ " -W sqlite-check Check metadata database integrity and exit.\n\n"
+ " -W sqlite-fix Check metadata database integrity, fix if needed and exit.\n\n"
+ " -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"
" 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"
+ " size of E MiB, an optional disk space limit\n"
" of F MiB and exit.\n\n"
#endif
" -W set section option value\n"
@@ -388,20 +394,6 @@ int help(int exitcode) {
return exitcode;
}
-// TODO: Remove this function with the nix major release.
-void remove_option(int opt_index, int *argc, char **argv) {
- int i;
-
- // remove the options.
- do {
- *argc = *argc - 1;
- for(i = opt_index; i < *argc; i++) {
- argv[i] = argv[i+1];
- }
- i = opt_index;
- } while(argv[i][0] != '-' && opt_index >= *argc);
-}
-
#ifdef ENABLE_HTTPS
static void security_init(){
char filename[FILENAME_MAX + 1];
@@ -556,7 +548,6 @@ static void get_netdata_configured_variables() {
// get default memory mode for the database
default_rrd_memory_mode = rrd_memory_mode_id(config_get(CONFIG_SECTION_GLOBAL, "memory mode", rrd_memory_mode_name(default_rrd_memory_mode)));
-
#ifdef ENABLE_DBENGINE
// ------------------------------------------------------------------------
// get default Database Engine page cache size in MiB
@@ -581,7 +572,11 @@ static void get_netdata_configured_variables() {
error("Invalid multidb disk space %d given. Defaulting to %d.", default_multidb_disk_quota_mb, default_rrdeng_disk_quota_mb);
default_multidb_disk_quota_mb = default_rrdeng_disk_quota_mb;
}
-
+#else
+ if (default_rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
+ error_report("RRD_MEMORY_MODE_DBENGINE is not supported in this platform. The agent will use memory mode ram instead.");
+ default_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
+ }
#endif
// ------------------------------------------------------------------------
@@ -733,34 +728,6 @@ int main(int argc, char **argv) {
// set the name for logging
program_name = "netdata";
- // parse deprecated options
- // TODO: Remove this block with the next major release.
- {
- i = 1;
- while(i < argc) {
- if(strcmp(argv[i], "-pidfile") == 0 && (i+1) < argc) {
- strncpyz(pidfile, argv[i+1], FILENAME_MAX);
- fprintf(stderr, "%s: deprecated option -- %s -- please use -P instead.\n", argv[0], argv[i]);
- remove_option(i, &argc, argv);
- }
- else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(argv[i], "-nd") == 0) {
- dont_fork = 1;
- fprintf(stderr, "%s: deprecated option -- %s -- please use -D instead.\n ", argv[0], argv[i]);
- remove_option(i, &argc, argv);
- }
- else if(strcmp(argv[i], "-ch") == 0 && (i+1) < argc) {
- config_set(CONFIG_SECTION_GLOBAL, "host access prefix", argv[i+1]);
- fprintf(stderr, "%s: deprecated option -- %s -- please use -s instead.\n", argv[0], argv[i]);
- remove_option(i, &argc, argv);
- }
- else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) {
- config_set(CONFIG_SECTION_GLOBAL, "history", argv[i+1]);
- fprintf(stderr, "%s: deprecated option -- %s -- This option will be removed with V2.*.\n", argv[0], argv[i]);
- remove_option(i, &argc, argv);
- }
- else i++;
- }
- }
if (argc > 1 && strcmp(argv[1], SPAWN_SERVER_COMMAND_LINE_ARGUMENT) == 0) {
// don't run netdata, this is the spawn server
spawn_server();
@@ -840,6 +807,20 @@ int main(int argc, char **argv) {
char* createdataset_string = "createdataset=";
char* stresstest_string = "stresstest=";
#endif
+ if(strcmp(optarg, "sqlite-check") == 0) {
+ sql_init_database(DB_CHECK_INTEGRITY);
+ return 0;
+ }
+
+ if(strcmp(optarg, "sqlite-fix") == 0) {
+ sql_init_database(DB_CHECK_FIX_DB);
+ return 0;
+ }
+
+ if(strcmp(optarg, "sqlite-compact") == 0) {
+ sql_init_database(DB_CHECK_RECLAIM_SPACE);
+ return 0;
+ }
if(strcmp(optarg, "unittest") == 0) {
if(unit_test_buffer()) return 1;
@@ -861,9 +842,15 @@ int main(int argc, char **argv) {
#ifdef ENABLE_DBENGINE
if(test_dbengine()) return 1;
#endif
+ if(test_sqlite()) return 1;
fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
return 0;
}
+#ifdef ENABLE_ML_TESTS
+ else if(strcmp(optarg, "mltest") == 0) {
+ return test_ml(argc, argv);
+ }
+#endif
#ifdef ENABLE_DBENGINE
else if(strncmp(optarg, createdataset_string, strlen(createdataset_string)) == 0) {
optarg += strlen(createdataset_string);
@@ -1167,7 +1154,10 @@ int main(int argc, char **argv) {
// get log filenames and settings
log_init();
error_log_limit_unlimited();
+ // initialize the log files
+ open_all_log_files();
+ get_system_timezone();
// --------------------------------------------------------------------
// get the certificate and start security
#ifdef ENABLE_HTTPS
@@ -1180,6 +1170,10 @@ int main(int argc, char **argv) {
health_initialize_global_silencers();
// --------------------------------------------------------------------
+ // Initialize ML configuration
+ ml_init();
+
+ // --------------------------------------------------------------------
// setup process signals
// block signals while initializing threads.
@@ -1217,9 +1211,6 @@ int main(int argc, char **argv) {
api_listen_sockets_setup();
}
- // initialize the log files
- open_all_log_files();
-
#ifdef NETDATA_INTERNAL_CHECKS
if(debug_flags != 0) {
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
@@ -1269,6 +1260,7 @@ int main(int argc, char **argv) {
netdata_anonymous_statistics_enabled=-1;
struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info));
get_system_info(system_info);
+ system_info->hops = 0;
if(rrd_init(netdata_configured_hostname, system_info))
fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname);
@@ -1306,6 +1298,8 @@ int main(int argc, char **argv) {
netdata_zero_metrics_enabled = config_get_boolean_ondemand(CONFIG_SECTION_GLOBAL, "enable zero metrics", CONFIG_BOOLEAN_NO);
+ set_late_global_environment();
+
for (i = 0; static_threads[i].name != NULL ; i++) {
struct netdata_static_thread *st = &static_threads[i];
@@ -1325,8 +1319,6 @@ int main(int argc, char **argv) {
info("netdata initialization completed. Enjoy real-time performance monitoring!");
netdata_ready = 1;
- set_late_global_environment();
-
send_statistics("START", "-", "-");
if (crash_detected)
send_statistics("CRASH", "-", "-");