summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/main.c24
-rw-r--r--src/daemon/sentry-native/sentry-native.c11
-rw-r--r--src/daemon/sentry-native/sentry-native.h12
-rw-r--r--src/daemon/static_threads.c10
-rw-r--r--src/daemon/static_threads_freebsd.c10
-rw-r--r--src/daemon/static_threads_linux.c9
-rw-r--r--src/daemon/static_threads_macos.c10
7 files changed, 63 insertions, 23 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 30f7457537..6aa13adf65 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -475,7 +475,7 @@ void netdata_cleanup_and_exit(int ret, const char *action, const char *action_re
if (ret)
abort();
else {
- sentry_native_fini();
+ nd_sentry_fini();
exit(ret);
}
#else
@@ -795,6 +795,7 @@ int help(int exitcode) {
" -W sqlite-meta-recover Run recovery on the metadata database and exit.\n\n"
" -W sqlite-compact Reclaim metadata database unused space and exit.\n\n"
" -W sqlite-analyze Run update statistics and exit.\n\n"
+ " -W sqlite-alert-cleanup Perform maintenance on the alerts table.\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,G\n"
@@ -1515,6 +1516,11 @@ int main(int argc, char **argv) {
return 0;
}
+ if(strcmp(optarg, "sqlite-alert-cleanup") == 0) {
+ sql_alert_cleanup(true);
+ return 0;
+ }
+
if(strcmp(optarg, "unittest") == 0) {
unittest_running = true;
@@ -1883,9 +1889,6 @@ int main(int argc, char **argv) {
load_cloud_conf(0);
}
- // @stelfrag: Where is the right place to call this?
- watcher_thread_start();
-
// ------------------------------------------------------------------------
// initialize netdata
{
@@ -2104,9 +2107,11 @@ int main(int argc, char **argv) {
if(become_daemon(dont_fork, user) == -1)
fatal("Cannot daemonize myself.");
+ watcher_thread_start();
+
// init sentry
#ifdef ENABLE_SENTRY
- sentry_native_init();
+ nd_sentry_init();
#endif
// The "HOME" env var points to the root's home dir because Netdata starts as root. Can't use "HOME".
@@ -2153,7 +2158,14 @@ int main(int argc, char **argv) {
struct rrdhost_system_info *system_info = callocz(1, sizeof(struct rrdhost_system_info));
__atomic_sub_fetch(&netdata_buffers_statistics.rrdhost_allocations_size, sizeof(struct rrdhost_system_info), __ATOMIC_RELAXED);
get_system_info(system_info);
- (void) registry_get_this_machine_guid();
+
+ const char *guid = registry_get_this_machine_guid();
+#ifdef ENABLE_SENTRY
+ nd_sentry_set_user(guid);
+#else
+ UNUSED(guid);
+#endif
+
system_info->hops = 0;
get_install_type(&system_info->install_type, &system_info->prebuilt_arch, &system_info->prebuilt_dist);
diff --git a/src/daemon/sentry-native/sentry-native.c b/src/daemon/sentry-native/sentry-native.c
index 3594c1fffa..2d984fa36d 100644
--- a/src/daemon/sentry-native/sentry-native.c
+++ b/src/daemon/sentry-native/sentry-native.c
@@ -19,7 +19,7 @@ static bool sentry_telemetry_disabled(void)
return getenv("DISABLE_TELEMETRY") != NULL;
}
-void sentry_native_init(void)
+void nd_sentry_init(void)
{
if (sentry_telemetry_disabled())
return;
@@ -41,10 +41,17 @@ void sentry_native_init(void)
sentry_init(options);
}
-void sentry_native_fini(void)
+void nd_sentry_fini(void)
{
if (sentry_telemetry_disabled())
return;
sentry_close();
}
+
+void nd_sentry_set_user(const char *guid)
+{
+ sentry_value_t user = sentry_value_new_object();
+ sentry_value_set_by_key(user, "id", sentry_value_new_string(guid));
+ sentry_set_user(user);
+}
diff --git a/src/daemon/sentry-native/sentry-native.h b/src/daemon/sentry-native/sentry-native.h
index 861c5b9595..81f909d9fb 100644
--- a/src/daemon/sentry-native/sentry-native.h
+++ b/src/daemon/sentry-native/sentry-native.h
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later
-#ifndef SENTRY_NATIVE_H
-#define SENTRY_NATIVE_H
+#ifndef ND_SENTRY_H
+#define ND_SENTRY_H
-void sentry_native_init(void);
-void sentry_native_fini(void);
+void nd_sentry_init(void);
+void nd_sentry_fini(void);
-#endif /* SENTRY_NATIVE_H */
+void nd_sentry_set_user(const char *guid);
+
+#endif /* ND_SENTRY_H */
diff --git a/src/daemon/static_threads.c b/src/daemon/static_threads.c
index e03819761e..9f0db6e1af 100644
--- a/src/daemon/static_threads.c
+++ b/src/daemon/static_threads.c
@@ -12,7 +12,6 @@ void *health_main(void *ptr);
void *pluginsd_main(void *ptr);
void *service_main(void *ptr);
void *statsd_main(void *ptr);
-void *timex_main(void *ptr);
void *profile_main(void *ptr);
void *replication_thread_main(void *ptr);
@@ -20,15 +19,6 @@ extern bool global_statistics_enabled;
const struct netdata_static_thread static_threads_common[] = {
{
- .name = "P[timex]",
- .config_section = CONFIG_SECTION_PLUGINS,
- .config_name = "timex",
- .enabled = 1,
- .thread = NULL,
- .init_routine = NULL,
- .start_routine = timex_main
- },
- {
.name = "P[idlejitter]",
.config_section = CONFIG_SECTION_PLUGINS,
.config_name = "idlejitter",
diff --git a/src/daemon/static_threads_freebsd.c b/src/daemon/static_threads_freebsd.c
index cc150faf9a..b354b9c2a5 100644
--- a/src/daemon/static_threads_freebsd.c
+++ b/src/daemon/static_threads_freebsd.c
@@ -3,6 +3,7 @@
#include "common.h"
extern void *freebsd_main(void *ptr);
+extern void *timex_main(void *ptr);
const struct netdata_static_thread static_threads_freebsd[] = {
{
@@ -14,6 +15,15 @@ const struct netdata_static_thread static_threads_freebsd[] = {
.init_routine = NULL,
.start_routine = freebsd_main
},
+ {
+ .name = "P[timex]",
+ .config_section = CONFIG_SECTION_PLUGINS,
+ .config_name = "timex",
+ .enabled = 1,
+ .thread = NULL,
+ .init_routine = NULL,
+ .start_routine = timex_main
+ },
{NULL, NULL, NULL, 0, NULL, NULL, NULL}
};
diff --git a/src/daemon/static_threads_linux.c b/src/daemon/static_threads_linux.c
index 54307eccff..6939189978 100644
--- a/src/daemon/static_threads_linux.c
+++ b/src/daemon/static_threads_linux.c
@@ -45,6 +45,15 @@ const struct netdata_static_thread static_threads_linux[] = {
.init_routine = NULL,
.start_routine = cgroups_main
},
+ {
+ .name = "P[timex]",
+ .config_section = CONFIG_SECTION_PLUGINS,
+ .config_name = "timex",
+ .enabled = 1,
+ .thread = NULL,
+ .init_routine = NULL,
+ .start_routine = timex_main
+ },
// terminator
{
diff --git a/src/daemon/static_threads_macos.c b/src/daemon/static_threads_macos.c
index aaf7df6f64..f4a33e8553 100644
--- a/src/daemon/static_threads_macos.c
+++ b/src/daemon/static_threads_macos.c
@@ -3,9 +3,19 @@
#include "common.h"
extern void *macos_main(void *ptr);
+extern void *timex_main(void *ptr);
const struct netdata_static_thread static_threads_macos[] = {
{
+ .name = "P[timex]",
+ .config_section = CONFIG_SECTION_PLUGINS,
+ .config_name = "timex",
+ .enabled = 1,
+ .thread = NULL,
+ .init_routine = NULL,
+ .start_routine = timex_main
+ },
+ {
.name = "P[macos]",
.config_section = CONFIG_SECTION_PLUGINS,
.config_name = "macos",