// SPDX-License-Identifier: GPL-3.0-or-later
#include "common.h"
int netdata_zero_metrics_enabled;
int netdata_anonymous_statistics_enabled;
struct config netdata_config = {
.sections = NULL,
.mutex = NETDATA_MUTEX_INITIALIZER,
.index = {
.avl_tree = {
.root = NULL,
.compar = appconfig_section_compare
},
.rwlock = AVL_LOCK_INITIALIZER
}
};
void netdata_cleanup_and_exit(int ret) {
// enabling this, is wrong
// because the threads will be cancelled while cleaning up
// netdata_exit = 1;
error_log_limit_unlimited();
info("EXIT: netdata prepares to exit with code %d...", ret);
send_statistics("EXIT", ret?"ERROR":"OK","-");
// cleanup/save the database and exit
info("EXIT: cleaning up the database...");
rrdhost_cleanup_all();
if(!ret) {
// exit cleanly
// stop everything
info("EXIT: stopping master threads...");
cancel_main_threads();
// free the database
info("EXIT: freeing database memory...");
rrdhost_free_all();
}
// unlink the pid
if(pidfile[0]) {
info("EXIT: removing netdata PID file '%s'...", pidfile);
if(unlink(pidfile) != 0)
error("EXIT: cannot unlink pidfile '%s'.", pidfile);
}
#ifdef ENABLE_HTTPS
security_clean_openssl();
#endif
info("EXIT: all done - netdata is now exiting - bye bye...");
exit(ret);
}
struct netdata_static_thread static_threads[] = {
NETDATA_PLUGIN_HOOK_CHECKS
NETDATA_PLUGIN_HOOK_FREEBSD
NETDATA_PLUGIN_HOOK_MACOS
// linux internal plugins
NETDATA_PLUGIN_HOOK_LINUX_PROC
NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE
NETDATA_PLUGIN_HOOK_LINUX_CGROUPS
NETDATA_PLUGIN_HOOK_LINUX_TC
NETDATA_PLUGIN_HOOK_IDLEJITTER
NETDATA_PLUGIN_HOOK_STATSD