@cryptotaxi247 / netdata-1 / commits / 37082fcbc

Compute platform-specific list of static_threads at runtime. (#11955)

Compute array of static threads at runtime.

vkalintiris committed Jan 19, 2022 at 08:54 UTC 37082fcbc150619b54b2a64c3621afc617607adc
41 files changed +397 -465
CMakeLists.txt
+9 -16
@@ -57,22 +57,15 @@ SET(MACOS False)
57
58 # Detect the operating system
59 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
60 - SET(TARGET_OS_NAME "macos")
61 - SET(TARGET_OS 3)
60 SET(MACOS True)
61 ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
64 - SET(TARGET_OS_NAME "freebsd")
65 - SET(TARGET_OS 2)
62 SET(FREEBSD True)
63 ELSE()
68 - SET(TARGET_OS_NAME "linux")
69 - SET(TARGET_OS 1)
64 SET(LINUX True)
65 ENDIF()
66
67 # show the operating system on the console
74 -message(STATUS "operating system: ${TARGET_OS_NAME} (TARGET_OS=${TARGET_OS})")
75 -
68 +message(STATUS "system name: ${CMAKE_SYSTEM_NAME}")
69
70 # -----------------------------------------------------------------------------
71 # Detect libuuid
@@ -430,7 +423,6 @@ set(APPS_PLUGIN_FILES
423
424 set(CHECKS_PLUGIN_FILES
425 collectors/checks.plugin/plugin_checks.c
433 - collectors/checks.plugin/plugin_checks.h
426 )
427
428 set(FREEBSD_PLUGIN_FILES
@@ -455,7 +447,6 @@ set(HEALTH_PLUGIN_FILES
447
448 set(IDLEJITTER_PLUGIN_FILES
449 collectors/idlejitter.plugin/plugin_idlejitter.c
458 - collectors/idlejitter.plugin/plugin_idlejitter.h
450 )
451
452 set(CGROUPS_PLUGIN_FILES
@@ -468,12 +459,10 @@ set(CGROUP_NETWORK_FILES
459 )
460
461 set(DISKSPACE_PLUGIN_FILES
471 - collectors/diskspace.plugin/plugin_diskspace.h
462 collectors/diskspace.plugin/plugin_diskspace.c
463 )
464
465 set(TIMEX_PLUGIN_FILES
476 - collectors/timex.plugin/plugin_timex.h
466 collectors/timex.plugin/plugin_timex.c
467 )
468
@@ -585,7 +574,6 @@ set(PROC_PLUGIN_FILES
574
575 set(TC_PLUGIN_FILES
576 collectors/tc.plugin/plugin_tc.c
588 - collectors/tc.plugin/plugin_tc.h
577 )
578
579 set(MACOS_PLUGIN_FILES
@@ -626,7 +614,6 @@ set(REGISTRY_PLUGIN_FILES
614
615 set(STATSD_PLUGIN_FILES
616 collectors/statsd.plugin/statsd.c
629 - collectors/statsd.plugin/statsd.h
617 )
618
619 set(RRD_PLUGIN_FILES
@@ -928,7 +915,8 @@ set(DAEMON_FILES
915 daemon/signals.c
916 daemon/signals.h
917 daemon/service.c
931 - daemon/service.h
918 + daemon/static_threads.c
919 + daemon/static_threads.h
920 daemon/commands.c
921 daemon/commands.h
922 daemon/unit_test.c
@@ -997,7 +985,6 @@ include_directories(AFTER .)
985
986 add_definitions(
987 -DHAVE_CONFIG_H
1000 - -DTARGET_OS=${TARGET_OS}
988 -DCACHE_DIR="/var/cache/netdata"
989 -DCONFIG_DIR="/etc/netdata"
990 -DLIBCONFIG_DIR="/usr/lib/netdata/conf.d"
@@ -1186,7 +1173,9 @@ include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include)
1173 # netdata
1174
1175 IF(LINUX)
1176 + list(APPEND NETDATA_FILES daemon/static_threads_linux.c)
1177 list(APPEND NETDATA_COMMON_LIBRARIES rt)
1178 +
1179 add_executable(netdata config.h ${NETDATA_FILES}
1180 ${CGROUPS_PLUGIN_FILES}
1181 ${DISKSPACE_PLUGIN_FILES}
@@ -1204,6 +1193,8 @@ IF(LINUX)
1193 SET(ENABLE_PLUGIN_SLABINFO True)
1194
1195 ELSEIF(FREEBSD)
1196 + list(APPEND NETDATA_FILES daemon/static_threads_freebsd.c)
1197 +
1198 add_executable(netdata config.h ${NETDATA_FILES} ${FREEBSD_PLUGIN_FILES})
1199 target_link_libraries (netdata libnetdata ${NETDATA_COMMON_LIBRARIES})
1200 target_include_directories(netdata PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
@@ -1215,6 +1206,8 @@ ELSEIF(FREEBSD)
1206 SET(ENABLE_PLUGIN_EBPF False)
1207
1208 ELSEIF(MACOS)
1209 + list(APPEND NETDATA_FILES daemon/static_threads_macos.c)
1210 +
1211 add_executable(netdata config.h ${NETDATA_FILES} ${MACOS_PLUGIN_FILES})
1212 target_link_libraries (netdata libnetdata ${NETDATA_COMMON_LIBRARIES} ${IOKIT} ${FOUNDATION})
1213 target_include_directories(netdata PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
Makefile.am
+5 -8
@@ -201,7 +201,6 @@ APPS_PLUGIN_FILES = \
201
202 CHECKS_PLUGIN_FILES = \
203 collectors/checks.plugin/plugin_checks.c \
204 - collectors/checks.plugin/plugin_checks.h \
204 $(NULL)
205
206 FREEBSD_PLUGIN_FILES = \
@@ -271,7 +270,6 @@ endif
270
271 IDLEJITTER_PLUGIN_FILES = \
272 collectors/idlejitter.plugin/plugin_idlejitter.c \
274 - collectors/idlejitter.plugin/plugin_idlejitter.h \
273 $(NULL)
274
275 CGROUPS_PLUGIN_FILES = \
@@ -285,12 +283,10 @@ CGROUP_NETWORK_FILES = \
283 $(NULL)
284
285 DISKSPACE_PLUGIN_FILES = \
288 - collectors/diskspace.plugin/plugin_diskspace.h \
286 collectors/diskspace.plugin/plugin_diskspace.c \
287 $(NULL)
288
289 TIMEX_PLUGIN_FILES = \
293 - collectors/timex.plugin/plugin_timex.h \
290 collectors/timex.plugin/plugin_timex.c \
291 $(NULL)
292
@@ -413,7 +409,6 @@ PROC_PLUGIN_FILES = \
409
410 TC_PLUGIN_FILES = \
411 collectors/tc.plugin/plugin_tc.c \
416 - collectors/tc.plugin/plugin_tc.h \
412 $(NULL)
413
414 MACOS_PLUGIN_FILES = \
@@ -571,7 +566,6 @@ REGISTRY_PLUGIN_FILES = \
566
567 STATSD_PLUGIN_FILES = \
568 collectors/statsd.plugin/statsd.c \
574 - collectors/statsd.plugin/statsd.h \
569 $(NULL)
570
571 WEB_PLUGIN_FILES = \
@@ -869,7 +863,8 @@ DAEMON_FILES = \
863 daemon/signals.c \
864 daemon/signals.h \
865 daemon/service.c \
872 - daemon/service.h \
866 + daemon/static_threads.h \
867 + daemon/static_threads.c \
868 daemon/commands.c \
869 daemon/commands.h \
870 daemon/unit_test.c \
@@ -904,25 +899,27 @@ NETDATA_FILES = \
899
900 if FREEBSD
901 NETDATA_FILES += \
902 + daemon/static_threads_freebsd.c \
903 $(FREEBSD_PLUGIN_FILES) \
904 $(NULL)
905 endif
906
907 if MACOS
908 NETDATA_FILES += \
909 + daemon/static_threads_macos.c \
910 $(MACOS_PLUGIN_FILES) \
911 $(NULL)
912 endif
913
914 if LINUX
915 NETDATA_FILES += \
916 + daemon/static_threads_linux.c \
917 $(CGROUPS_PLUGIN_FILES) \
918 $(DISKSPACE_PLUGIN_FILES) \
919 $(TIMEX_PLUGIN_FILES) \
920 $(PROC_PLUGIN_FILES) \
921 $(TC_PLUGIN_FILES) \
922 $(NULL)
925 -
923 endif
924
925 NETDATA_COMMON_LIBS = \
collectors/all.h
-12
@@ -7,20 +7,8 @@
7
8 // netdata internal data collection plugins
9
10 -#include "checks.plugin/plugin_checks.h"
11 -#include "freebsd.plugin/plugin_freebsd.h"
12 -#include "idlejitter.plugin/plugin_idlejitter.h"
13 -#include "cgroups.plugin/sys_fs_cgroup.h"
14 -#include "diskspace.plugin/plugin_diskspace.h"
15 -#include "timex.plugin/plugin_timex.h"
16 -#include "proc.plugin/plugin_proc.h"
17 -#include "tc.plugin/plugin_tc.h"
18 -#include "macos.plugin/plugin_macos.h"
19 -#include "statsd.plugin/statsd.h"
20 -
10 #include "plugins.d/plugins_d.h"
11
23 -
12 // ----------------------------------------------------------------------------
13 // netdata chart priorities
14
collectors/cgroups.plugin/sys_fs_cgroup.h
-21
@@ -5,21 +5,6 @@
5
6 #include "daemon/common.h"
7
8 -#if (TARGET_OS == OS_LINUX)
9 -
10 -#define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS \
11 - { \
12 - .name = "PLUGIN[cgroups]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "cgroups", \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = cgroups_main \
19 - },
20 -
21 -extern void *cgroups_main(void *ptr);
22 -
8 #define CGROUP_OPTIONS_DISABLED_DUPLICATE 0x00000001
9 #define CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE 0x00000002
10 #define CGROUP_OPTIONS_IS_UNIFIED 0x00000004
@@ -54,12 +39,6 @@ typedef struct netdata_ebpf_cgroup_shm {
39
40 #include "../proc.plugin/plugin_proc.h"
41
57 -#else // (TARGET_OS == OS_LINUX)
58 -
59 -#define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS
60 -
61 -#endif // (TARGET_OS == OS_LINUX)
62 -
42 extern char *parse_k8s_data(struct label **labels, char *data);
43
44 #endif //NETDATA_SYS_FS_CGROUP_H
collectors/checks.plugin/plugin_checks.c
+1 -5
@@ -1,8 +1,6 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "plugin_checks.h"
4 -
5 -#ifdef NETDATA_INTERNAL_CHECKS
3 +#include "daemon/common.h"
4
5 static void checks_main_cleanup(void *ptr) {
6 struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
@@ -125,5 +123,3 @@ void *checks_main(void *ptr) {
123 netdata_thread_cleanup_pop(1);
124 return NULL;
125 }
128 -
129 -#endif // NETDATA_INTERNAL_CHECKS
collectors/checks.plugin/plugin_checks.h deleted
-29
@@ -1,29 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_PLUGIN_CHECKS_H
4 -#define NETDATA_PLUGIN_CHECKS_H 1
5 -
6 -#include "daemon/common.h"
7 -
8 -#ifdef NETDATA_INTERNAL_CHECKS
9 -
10 -#define NETDATA_PLUGIN_HOOK_CHECKS \
11 - { \
12 - .name = "PLUGIN[check]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "checks", \
15 - .enabled = 0, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = checks_main \
19 - },
20 -
21 -extern void *checks_main(void *ptr);
22 -
23 -#else // !NETDATA_INTERNAL_CHECKS
24 -
25 -#define NETDATA_PLUGIN_HOOK_CHECKS
26 -
27 -#endif // NETDATA_INTERNAL_CHECKS
28 -
29 -#endif // NETDATA_PLUGIN_CHECKS_H
collectors/diskspace.plugin/plugin_diskspace.c
+1 -1
@@ -1,6 +1,6 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "plugin_diskspace.h"
3 +#include "../proc.plugin/plugin_proc.h"
4
5 #define PLUGIN_DISKSPACE_NAME "diskspace.plugin"
6
collectors/diskspace.plugin/plugin_diskspace.h deleted
-34
@@ -1,34 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_PLUGIN_PROC_DISKSPACE_H
4 -#define NETDATA_PLUGIN_PROC_DISKSPACE_H
5 -
6 -#include "daemon/common.h"
7 -
8 -
9 -#if (TARGET_OS == OS_LINUX)
10 -
11 -#define NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE \
12 - { \
13 - .name = "PLUGIN[diskspace]", \
14 - .config_section = CONFIG_SECTION_PLUGINS, \
15 - .config_name = "diskspace", \
16 - .enabled = 1, \
17 - .thread = NULL, \
18 - .init_routine = NULL, \
19 - .start_routine = diskspace_main \
20 - },
21 -
22 -extern void *diskspace_main(void *ptr);
23 -
24 -#include "../proc.plugin/plugin_proc.h"
25 -
26 -#else // (TARGET_OS == OS_LINUX)
27 -
28 -#define NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE
29 -
30 -#endif // (TARGET_OS == OS_LINUX)
31 -
32 -
33 -
34 -#endif //NETDATA_PLUGIN_PROC_DISKSPACE_H
collectors/ebpf.plugin/ebpf.h
+1
@@ -27,6 +27,7 @@
27 #include "libnetdata/config/appconfig.h"
28 #include "libnetdata/ebpf/ebpf.h"
29 #include "libnetdata/procfile/procfile.h"
30 +#include "collectors/cgroups.plugin/sys_fs_cgroup.h"
31 #include "daemon/main.h"
32
33 #include "ebpf_apps.h"
collectors/freebsd.plugin/plugin_freebsd.h
-22
@@ -5,20 +5,6 @@
5
6 #include "daemon/common.h"
7
8 -#if (TARGET_OS == OS_FREEBSD)
9 -
10 -#define NETDATA_PLUGIN_HOOK_FREEBSD \
11 - { \
12 - .name = "PLUGIN[freebsd]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "freebsd", \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = freebsd_main \
19 - },
20 -
21 -
8 #include <sys/sysctl.h>
9
10 #define KILO_FACTOR 1024
@@ -27,8 +13,6 @@
13
14 #define MAX_INT_DIGITS 10 // maximum number of digits for int
15
30 -void *freebsd_main(void *ptr);
31 -
16 extern int freebsd_plugin_init();
17
18 extern int do_vm_loadavg(int update_every, usec_t dt);
@@ -65,10 +49,4 @@ extern int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt);
49 extern int do_kstat_zfs_misc_zio_trim(int update_every, usec_t dt);
50 extern int do_ipfw(int update_every, usec_t dt);
51
68 -#else // (TARGET_OS == OS_FREEBSD)
69 -
70 -#define NETDATA_PLUGIN_HOOK_FREEBSD
71 -
72 -#endif // (TARGET_OS == OS_FREEBSD)
73 -
52 #endif /* NETDATA_PLUGIN_FREEBSD_H */
collectors/idlejitter.plugin/plugin_idlejitter.c
+1 -1
@@ -1,6 +1,6 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "plugin_idlejitter.h"
3 +#include "daemon/common.h"
4
5 #define CPU_IDLEJITTER_SLEEP_TIME_MS 20
6
collectors/idlejitter.plugin/plugin_idlejitter.h deleted
-21
@@ -1,21 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_PLUGIN_IDLEJITTER_H
4 -#define NETDATA_PLUGIN_IDLEJITTER_H 1
5 -
6 -#include "daemon/common.h"
7 -
8 -#define NETDATA_PLUGIN_HOOK_IDLEJITTER \
9 - { \
10 - .name = "PLUGIN[idlejitter]", \
11 - .config_section = CONFIG_SECTION_PLUGINS, \
12 - .config_name = "idlejitter", \
13 - .enabled = 1, \
14 - .thread = NULL, \
15 - .init_routine = NULL, \
16 - .start_routine = cpuidlejitter_main \
17 - },
18 -
19 -extern void *cpuidlejitter_main(void *ptr);
20 -
21 -#endif /* NETDATA_PLUGIN_IDLEJITTER_H */
collectors/macos.plugin/plugin_macos.h
-31
@@ -1,43 +1,12 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -
3 #ifndef NETDATA_PLUGIN_MACOS_H
4 #define NETDATA_PLUGIN_MACOS_H 1
5
6 #include "daemon/common.h"
7
9 -#if (TARGET_OS == OS_MACOS)
10 -
11 -#define NETDATA_PLUGIN_HOOK_MACOS \
12 - { \
13 - .name = "PLUGIN[macos]", \
14 - .config_section = CONFIG_SECTION_PLUGINS, \
15 - .config_name = "macos", \
16 - .enabled = 1, \
17 - .thread = NULL, \
18 - .init_routine = NULL, \
19 - .start_routine = macos_main \
20 - },
21 -
22 -void *macos_main(void *ptr);
23 -
24 -#define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var))
25 -
26 -extern int getsysctl_by_name(const char *name, void *ptr, size_t len);
27 -
8 extern int do_macos_sysctl(int update_every, usec_t dt);
9 extern int do_macos_mach_smi(int update_every, usec_t dt);
10 extern int do_macos_iokit(int update_every, usec_t dt);
11
32 -
33 -#else // (TARGET_OS == OS_MACOS)
34 -
35 -#define NETDATA_PLUGIN_HOOK_MACOS
36 -
37 -#endif // (TARGET_OS == OS_MACOS)
38 -
39 -
40 -
41 -
42 -
12 #endif /* NETDATA_PLUGIN_MACOS_H */
collectors/plugins.d/plugins_d.h
-14
@@ -5,18 +5,6 @@
5
6 #include "daemon/common.h"
7
8 -#define NETDATA_PLUGIN_HOOK_PLUGINSD \
9 - { \
10 - .name = "PLUGINSD", \
11 - .config_section = NULL, \
12 - .config_name = NULL, \
13 - .enabled = 1, \
14 - .thread = NULL, \
15 - .init_routine = NULL, \
16 - .start_routine = pluginsd_main \
17 - },
18 -
19 -
8 #define PLUGINSD_FILE_SUFFIX ".plugin"
9 #define PLUGINSD_FILE_SUFFIX_LEN strlen(PLUGINSD_FILE_SUFFIX)
10 #define PLUGINSD_CMD_MAX (FILENAME_MAX*2)
@@ -71,8 +59,6 @@ struct plugind {
59
60 extern struct plugind *pluginsd_root;
61
74 -extern void *pluginsd_main(void *ptr);
75 -
62 extern size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations);
63 extern int pluginsd_split_words(char *str, char **words, int max_words, char *recover_string, char **recover_location, int max_recover);
64
collectors/proc.plugin/plugin_proc.h
-23
@@ -5,25 +5,9 @@
5
6 #include "daemon/common.h"
7
8 -#if (TARGET_OS == OS_LINUX)
9 -
10 -#define NETDATA_PLUGIN_HOOK_LINUX_PROC \
11 - { \
12 - .name = "PLUGIN[proc]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "proc", \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = proc_main \
19 - },
20 -
21 -
8 #define PLUGIN_PROC_CONFIG_NAME "proc"
9 #define PLUGIN_PROC_NAME PLUGIN_PROC_CONFIG_NAME ".plugin"
10
25 -extern void *proc_main(void *ptr);
26 -
11 extern int do_proc_net_dev(int update_every, usec_t dt);
12 extern int do_proc_net_wireless(int update_every, usec_t dt);
13 extern int do_proc_diskstats(int update_every, usec_t dt);
@@ -74,11 +58,4 @@ extern void netdev_rename_device_del(const char *host_device);
58 #include "proc_pressure.h"
59 #include "zfs_common.h"
60
77 -#else // (TARGET_OS == OS_LINUX)
78 -
79 -#define NETDATA_PLUGIN_HOOK_LINUX_PROC
80 -
81 -#endif // (TARGET_OS == OS_LINUX)
82 -
83 -
61 #endif /* NETDATA_PLUGIN_PROC_H */
collectors/statsd.plugin/statsd.c
+4 -1
@@ -1,11 +1,14 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "statsd.h"
3 +#include "daemon/common.h"
4
5 #define STATSD_CHART_PREFIX "statsd"
6
7 #define PLUGIN_STATSD_NAME "statsd.plugin"
8
9 +#define STATSD_LISTEN_PORT 8125
10 +#define STATSD_LISTEN_BACKLOG 4096
11 +
12 // --------------------------------------------------------------------------------------
13
14 // #define STATSD_MULTITHREADED 1
collectors/statsd.plugin/statsd.h deleted
-25
@@ -1,25 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_STATSD_H
4 -#define NETDATA_STATSD_H 1
5 -
6 -#include "daemon/common.h"
7 -
8 -#define STATSD_LISTEN_PORT 8125
9 -#define STATSD_LISTEN_BACKLOG 4096
10 -
11 -#define NETDATA_PLUGIN_HOOK_STATSD \
12 - { \
13 - .name = "STATSD", \
14 - .config_section = NULL, \
15 - .config_name = NULL, \
16 - .enabled = 1, \
17 - .thread = NULL, \
18 - .init_routine = NULL, \
19 - .start_routine = statsd_main \
20 - },
21 -
22 -
23 -extern void *statsd_main(void *ptr);
24 -
25 -#endif //NETDATA_STATSD_H
collectors/tc.plugin/plugin_tc.c
+1 -1
@@ -1,6 +1,6 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "plugin_tc.h"
3 +#include "daemon/common.h"
4
5 #define RRD_TYPE_TC "tc"
6 #define PLUGIN_TC_NAME "tc.plugin"
collectors/tc.plugin/plugin_tc.h deleted
-31
@@ -1,31 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_PLUGIN_TC_H
4 -#define NETDATA_PLUGIN_TC_H 1
5 -
6 -#include "daemon/common.h"
7 -
8 -#if (TARGET_OS == OS_LINUX)
9 -
10 -#define NETDATA_PLUGIN_HOOK_LINUX_TC \
11 - { \
12 - .name = "PLUGIN[tc]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "tc", \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = tc_main \
19 - },
20 -
21 -extern void *tc_main(void *ptr);
22 -
23 -#else // (TARGET_OS == OS_LINUX)
24 -
25 -#define NETDATA_PLUGIN_HOOK_LINUX_TC
26 -
27 -#endif // (TARGET_OS == OS_LINUX)
28 -
29 -
30 -#endif /* NETDATA_PLUGIN_TC_H */
31 -
collectors/timex.plugin/plugin_timex.c
+1 -1
@@ -1,6 +1,6 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 -#include "plugin_timex.h"
3 +#include "daemon/common.h"
4 #include "sys/timex.h"
5
6 #define PLUGIN_TIMEX_NAME "timex.plugin"
collectors/timex.plugin/plugin_timex.h deleted
-29
@@ -1,29 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_PLUGIN_TIMEX_H
4 -#define NETDATA_PLUGIN_TIMEX_H
5 -
6 -#include "daemon/common.h"
7 -
8 -#if (TARGET_OS == OS_LINUX)
9 -
10 -#define NETDATA_PLUGIN_HOOK_LINUX_TIMEX \
11 - { \
12 - .name = "PLUGIN[timex]", \
13 - .config_section = CONFIG_SECTION_PLUGINS, \
14 - .config_name = "timex", \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = timex_main \
19 - },
20 -
21 -extern void *timex_main(void *ptr);
22 -
23 -#else // (TARGET_OS == OS_LINUX)
24 -
25 -#define NETDATA_PLUGIN_HOOK_LINUX_TIMEX
26 -
27 -#endif // (TARGET_OS == OS_LINUX)
28 -
29 -#endif //NETDATA_PLUGIN_TIMEX_H
configure.ac
+1 -6
@@ -279,24 +279,21 @@ AC_MSG_CHECKING([operating system])
279 case "$host_os" in
280 freebsd*)
281 build_target=freebsd
282 - build_target_id=2
282 CFLAGS="${CFLAGS} -I/usr/local/include -L/usr/local/lib"
283 ;;
284 darwin*)
285 build_target=macos
287 - build_target_id=3
286 LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
287 ;;
288 *)
289 build_target=linux
292 - build_target_id=1
290 ;;
291 esac
292
293 AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
294 AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
295 AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
299 -AC_MSG_RESULT([${build_target} with id ${build_target_id}])
296 +AC_MSG_RESULT([Host OS: ${build_target}])
297
298
299 # -----------------------------------------------------------------------------
@@ -1538,7 +1535,6 @@ libconfigdir="${libdir}/netdata/conf.d"
1535 logdir="${localstatedir}/log/netdata"
1536 pluginsdir="${libexecdir}/netdata/plugins.d"
1537
1541 -AC_SUBST([build_target])
1538 AC_SUBST([varlibdir])
1539 AC_SUBST([registrydir])
1540 AC_SUBST([cachedir])
@@ -1560,7 +1556,6 @@ CFLAGS="${CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL
1556 CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
1557
1558 CPPFLAGS="\
1563 - -DTARGET_OS=${build_target_id} \
1559 -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
1560 -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
1561 -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
daemon/analytics.h
-12
@@ -17,17 +17,6 @@
17 #define ANALYTICS_MAX_JSON_HITS 255
18 #define ANALYTICS_MAX_DASHBOARD_HITS 255
19
20 -#define NETDATA_PLUGIN_HOOK_ANALYTICS \
21 - { \
22 - .name = "ANALYTICS", \
23 - .config_section = NULL, \
24 - .config_name = NULL, \
25 - .enabled = 0, \
26 - .thread = NULL, \
27 - .init_routine = NULL, \
28 - .start_routine = analytics_main \
29 - },
30 -
20 /* Needed to calculate the space needed for parameters */
21 #define ANALYTICS_NO_OF_ITEMS 39
22
@@ -80,7 +69,6 @@ struct analytics_data {
69 uint8_t dashboard_hits;
70 };
71
83 -extern void *analytics_main(void *ptr);
72 extern void analytics_get_data(char *name, BUFFER *wb);
73 extern void set_late_global_environment(void);
74 extern void analytics_free_data(void);
daemon/common.h
+1 -1
@@ -79,8 +79,8 @@
79 // the netdata daemon
80 #include "daemon.h"
81 #include "main.h"
82 +#include "static_threads.h"
83 #include "signals.h"
83 -#include "service.h"
84 #include "commands.h"
85 #include "analytics.h"
86
daemon/global_statistics.c
+1 -1
@@ -172,7 +172,7 @@ static inline void global_statistics_copy(struct global_statistics *gs, uint8_t
172 #endif
173 }
174
175 -void global_statistics_charts(void) {
175 +static void global_statistics_charts(void) {
176 static unsigned long long old_web_requests = 0,
177 old_web_usec = 0,
178 old_content_size = 0,
daemon/global_statistics.h
-12
@@ -8,17 +8,6 @@
8 // ----------------------------------------------------------------------------
9 // global statistics
10
11 -#define NETDATA_PLUGIN_HOOK_GLOBAL_STATISTICS \
12 - {.name = "GLOBAL_STATS", \
13 - .config_section = NULL, \
14 - .config_name = NULL, \
15 - .enabled = 1, \
16 - .thread = NULL, \
17 - .init_routine = NULL, \
18 - .start_routine = global_statistics_main},
19 -
20 -extern void *global_statistics_main(void *ptr);
21 -
11 extern void rrdr_query_completed(uint64_t db_points_read, uint64_t result_points_generated);
12
13 extern void finished_web_request_statistics(uint64_t dt,
@@ -29,6 +18,5 @@ extern void finished_web_request_statistics(uint64_t dt,
18
19 extern uint64_t web_client_connected(void);
20 extern void web_client_disconnected(void);
32 -extern void global_statistics_charts(void);
21
22 #endif /* NETDATA_GLOBAL_STATISTICS_H */
daemon/main.c
+6 -35
@@ -2,10 +2,13 @@
2
3 #include "common.h"
4 #include "buildinfo.h"
5 +#include "static_threads.h"
6
7 int netdata_zero_metrics_enabled;
8 int netdata_anonymous_statistics_enabled;
9
10 +struct netdata_static_thread *static_threads;
11 +
12 struct config netdata_config = {
13 .first_section = NULL,
14 .last_section = NULL,
@@ -76,41 +79,6 @@ void netdata_cleanup_and_exit(int ret) {
79 exit(ret);
80 }
81
79 -struct netdata_static_thread static_threads[] = {
80 - NETDATA_PLUGIN_HOOK_GLOBAL_STATISTICS
81 -
82 - NETDATA_PLUGIN_HOOK_CHECKS
83 - NETDATA_PLUGIN_HOOK_FREEBSD
84 - NETDATA_PLUGIN_HOOK_MACOS
85 -
86 - // linux internal plugins
87 - NETDATA_PLUGIN_HOOK_LINUX_PROC
88 - NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE
89 - NETDATA_PLUGIN_HOOK_LINUX_TIMEX
90 - NETDATA_PLUGIN_HOOK_LINUX_CGROUPS
91 - NETDATA_PLUGIN_HOOK_LINUX_TC
92 -
93 - NETDATA_PLUGIN_HOOK_IDLEJITTER
94 - NETDATA_PLUGIN_HOOK_STATSD
95 -
96 -#if defined(ENABLE_ACLK) || defined(ACLK_NG)
97 - NETDATA_ACLK_HOOK
98 -#endif
99 -
100 - // common plugins for all systems
101 - {"BACKENDS", NULL, NULL, 1, NULL, NULL, backends_main},
102 - {"EXPORTING", NULL, NULL, 1, NULL, NULL, exporting_main},
103 - {"WEB_SERVER[static1]", NULL, NULL, 0, NULL, NULL, socket_listen_main_static_threaded},
104 - {"STREAM", NULL, NULL, 0, NULL, NULL, rrdpush_sender_thread},
105 -
106 - NETDATA_PLUGIN_HOOK_PLUGINSD
107 - NETDATA_PLUGIN_HOOK_HEALTH
108 - NETDATA_PLUGIN_HOOK_ANALYTICS
109 - NETDATA_PLUGIN_HOOK_SERVICE
110 -
111 - {NULL, NULL, NULL, 0, NULL, NULL, NULL}
112 -};
113 -
82 void web_server_threading_selection(void) {
83 web_server_mode = web_server_mode_id(config_get(CONFIG_SECTION_WEB, "mode", web_server_mode_name(web_server_mode)));
84
@@ -281,6 +249,8 @@ void cancel_main_threads() {
249 }
250 else
251 info("All threads finished.");
252 +
253 + free(static_threads);
254 }
255
256 struct option_def option_definitions[] = {
@@ -723,6 +693,7 @@ int main(int argc, char **argv) {
693 size_t default_stacksize;
694 char *user = NULL;
695
696 + static_threads = static_threads_get();
697
698 netdata_ready=0;
699 // set the name for logging
daemon/main.h
-18
@@ -7,10 +7,6 @@
7
8 extern struct config netdata_config;
9
10 -#define NETDATA_MAIN_THREAD_RUNNING CONFIG_BOOLEAN_YES
11 -#define NETDATA_MAIN_THREAD_EXITING (CONFIG_BOOLEAN_YES + 1)
12 -#define NETDATA_MAIN_THREAD_EXITED CONFIG_BOOLEAN_NO
13 -
10 /**
11 * This struct contains information about command line options.
12 */
@@ -26,20 +22,6 @@ struct option_def {
22 const char *default_value;
23 };
24
29 -struct netdata_static_thread {
30 - char *name; // the name of the thread as it should appear in the logs
31 -
32 - char *config_section; // the section of netdata.conf to check if this is enabled or not
33 - char *config_name; // the name of the config option to check if it is true or false
34 -
35 - volatile sig_atomic_t enabled; // the current status of the thread
36 -
37 - netdata_thread_t *thread; // internal use, to maintain a pointer to the created thread
38 -
39 - void (*init_routine) (void); // an initialization function to run before spawning the thread
40 - void *(*start_routine) (void *); // the threaded worker
41 -};
42 -
25 extern void cancel_main_threads(void);
26 extern int killpid(pid_t pid);
27 extern void netdata_cleanup_and_exit(int ret) NORETURN;
daemon/service.c
+1 -1
@@ -5,7 +5,7 @@
5 /* Run service jobs every X seconds */
6 #define SERVICE_HEARTBEAT 10
7
8 -void service_main_cleanup(void *ptr)
8 +static void service_main_cleanup(void *ptr)
9 {
10 struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
11 static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
daemon/service.h deleted
-19
@@ -1,19 +0,0 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_SERVICE_H
4 -#define NETDATA_SERVICE_H 1
5 -
6 -#define NETDATA_PLUGIN_HOOK_SERVICE \
7 - { \
8 - .name = "SERVICE", \
9 - .config_section = NULL, \
10 - .config_name = NULL, \
11 - .enabled = 1, \
12 - .thread = NULL, \
13 - .init_routine = NULL, \
14 - .start_routine = service_main \
15 - },
16 -
17 -extern void *service_main(void *ptr);
18 -
19 -#endif //NETDATA_SERVICE_H
daemon/static_threads.c new
+161
@@ -0,0 +1,161 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "common.h"
4 +
5 +extern void *aclk_starter(void *ptr);
6 +extern void *analytics_main(void *ptr);
7 +extern void *checks_main(void *ptr);
8 +extern void *cpuidlejitter_main(void *ptr);
9 +extern void *global_statistics_main(void *ptr);
10 +extern void *health_main(void *ptr);
11 +extern void *pluginsd_main(void *ptr);
12 +extern void *service_main(void *ptr);
13 +extern void *statsd_main(void *ptr);
14 +
15 +const struct netdata_static_thread static_threads_common[] = {
16 + {
17 + .name = "PLUGIN[check]",
18 + .config_section = CONFIG_SECTION_PLUGINS,
19 + .config_name = "checks",
20 + .enabled = 0,
21 + .thread = NULL,
22 + .init_routine = NULL,
23 + .start_routine = checks_main
24 + },
25 + {
26 + .name = "PLUGIN[idlejitter]",
27 + .config_section = CONFIG_SECTION_PLUGINS,
28 + .config_name = "idlejitter",
29 + .enabled = 1,
30 + .thread = NULL,
31 + .init_routine = NULL,
32 + .start_routine = cpuidlejitter_main
33 + },
34 + {
35 + .name = "ANALYTICS",
36 + .config_section = NULL,
37 + .config_name = NULL,
38 + .enabled = 0,
39 + .thread = NULL,
40 + .init_routine = NULL,
41 + .start_routine = analytics_main
42 + },
43 + {
44 + .name = "GLOBAL_STATS",
45 + .config_section = NULL,
46 + .config_name = NULL,
47 + .enabled = 1,
48 + .thread = NULL,
49 + .init_routine = NULL,
50 + .start_routine = global_statistics_main
51 + },
52 + {
53 + .name = "HEALTH",
54 + .config_section = NULL,
55 + .config_name = NULL,
56 + .enabled = 1,
57 + .thread = NULL,
58 + .init_routine = NULL,
59 + .start_routine = health_main
60 + },
61 + {
62 + .name = "PLUGINSD",
63 + .config_section = NULL,
64 + .config_name = NULL,
65 + .enabled = 1,
66 + .thread = NULL,
67 + .init_routine = NULL,
68 + .start_routine = pluginsd_main
69 + },
70 + {
71 + .name = "SERVICE",
72 + .config_section = NULL,
73 + .config_name = NULL,
74 + .enabled = 1,
75 + .thread = NULL,
76 + .init_routine = NULL,
77 + .start_routine = service_main
78 + },
79 + {
80 + .name = "STATSD",
81 + .config_section = NULL,
82 + .config_name = NULL,
83 + .enabled = 1,
84 + .thread = NULL,
85 + .init_routine = NULL,
86 + .start_routine = statsd_main
87 + },
88 + {
89 + .name = "BACKENDS",
90 + .config_section = NULL,
91 + .config_name = NULL,
92 + .enabled = 1,
93 + .thread = NULL,
94 + .init_routine = NULL,
95 + .start_routine = backends_main
96 + },
97 + {
98 + .name = "EXPORTING",
99 + .config_section = NULL,
100 + .config_name = NULL,
101 + .enabled = 1,
102 + .thread = NULL,
103 + .init_routine = NULL,
104 + .start_routine = exporting_main
105 + },
106 + {
107 + .name = "STREAM",
108 + .config_section = NULL,
109 + .config_name = NULL,
110 + .enabled = 0,
111 + .thread = NULL,
112 + .init_routine = NULL,
113 + .start_routine = rrdpush_sender_thread
114 + },
115 + {
116 + .name = "WEB_SERVER[static1]",
117 + .config_section = NULL,
118 + .config_name = NULL,
119 + .enabled = 0,
120 + .thread = NULL,
121 + .init_routine = NULL,
122 + .start_routine = socket_listen_main_static_threaded
123 + },
124 +
125 +#if defined(ENABLE_ACLK) || defined(ACLK_NG)
126 + {
127 + .name = "ACLK_Main",
128 + .config_section = NULL,
129 + .config_name = NULL,
130 + .enabled = 1,
131 + .thread = NULL,
132 + .init_routine = NULL,
133 + .start_routine = aclk_starter
134 + },
135 +#endif
136 +
137 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
138 +};
139 +
140 +struct netdata_static_thread *
141 +static_threads_concat(const struct netdata_static_thread *lhs,
142 + const struct netdata_static_thread *rhs)
143 +{
144 + struct netdata_static_thread *res;
145 +
146 + int lhs_size = 0;
147 + for (; lhs[lhs_size].name; lhs_size++) {}
148 +
149 + int rhs_size = 0;
150 + for (; rhs[rhs_size].name; rhs_size++) {}
151 +
152 + res = callocz(lhs_size + rhs_size + 1, sizeof(struct netdata_static_thread));
153 +
154 + for (int i = 0; i != lhs_size; i++)
155 + memcpy(&res[i], &lhs[i], sizeof(struct netdata_static_thread));
156 +
157 + for (int i = 0; i != rhs_size; i++)
158 + memcpy(&res[lhs_size + i], &rhs[i], sizeof(struct netdata_static_thread));
159 +
160 + return res;
161 +}
daemon/static_threads.h new
+46
@@ -0,0 +1,46 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#ifndef NETDATA_STATIC_THREADS_H
4 +#define NETDATA_STATIC_THREADS_H
5 +
6 +#include "common.h"
7 +
8 +struct netdata_static_thread {
9 + // the name of the thread as it should appear in the logs
10 + char *name;
11 +
12 + // the section of netdata.conf to check if this is enabled or not
13 + char *config_section;
14 +
15 + // the name of the config option to check if it is true or false
16 + char *config_name;
17 +
18 + // the current status of the thread
19 + volatile sig_atomic_t enabled;
20 +
21 + // internal use, to maintain a pointer to the created thread
22 + netdata_thread_t *thread;
23 +
24 + // an initialization function to run before spawning the thread
25 + void (*init_routine) (void);
26 +
27 + // the threaded worker
28 + void *(*start_routine) (void *);
29 +};
30 +
31 +#define NETDATA_MAIN_THREAD_RUNNING CONFIG_BOOLEAN_YES
32 +#define NETDATA_MAIN_THREAD_EXITING (CONFIG_BOOLEAN_YES + 1)
33 +#define NETDATA_MAIN_THREAD_EXITED CONFIG_BOOLEAN_NO
34 +
35 +extern const struct netdata_static_thread static_threads_common[];
36 +extern const struct netdata_static_thread static_threads_linux[];
37 +extern const struct netdata_static_thread static_threads_freebsd[];
38 +extern const struct netdata_static_thread static_threads_macos[];
39 +
40 +struct netdata_static_thread *
41 +static_threads_concat(const struct netdata_static_thread *lhs,
42 + const struct netdata_static_thread *rhs);
43 +
44 +struct netdata_static_thread *static_threads_get();
45 +
46 +#endif /* NETDATA_STATIC_THREADS_H */
daemon/static_threads_freebsd.c new
+31
@@ -0,0 +1,31 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "common.h"
4 +
5 +extern void *freebsd_main(void *ptr);
6 +
7 +const struct netdata_static_thread static_threads_freebsd[] = {
8 + {
9 + .name = "PLUGIN[freebsd]",
10 + .config_section = CONFIG_SECTION_PLUGINS,
11 + .config_name = "freebsd",
12 + .enabled = 1,
13 + .thread = NULL,
14 + .init_routine = NULL,
15 + .start_routine = freebsd_main
16 + },
17 +
18 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
19 +};
20 +
21 +const struct netdata_static_thread static_threads_linux[] = {
22 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
23 +};
24 +
25 +const struct netdata_static_thread static_threads_macos[] = {
26 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
27 +};
28 +
29 +struct netdata_static_thread *static_threads_get() {
30 + return static_threads_concat(static_threads_common, static_threads_freebsd);
31 +}
daemon/static_threads_linux.c new
+71
@@ -0,0 +1,71 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "common.h"
4 +
5 +extern void *cgroups_main(void *ptr);
6 +extern void *proc_main(void *ptr);
7 +extern void *diskspace_main(void *ptr);
8 +extern void *tc_main(void *ptr);
9 +extern void *timex_main(void *ptr);
10 +
11 +const struct netdata_static_thread static_threads_linux[] = {
12 + {
13 + .name = "PLUGIN[timex]",
14 + .config_section = CONFIG_SECTION_PLUGINS,
15 + .config_name = "timex",
16 + .enabled = 1,
17 + .thread = NULL,
18 + .init_routine = NULL,
19 + .start_routine = timex_main
20 + },
21 + {
22 + .name = "PLUGIN[tc]",
23 + .config_section = CONFIG_SECTION_PLUGINS,
24 + .config_name = "tc",
25 + .enabled = 1,
26 + .thread = NULL,
27 + .init_routine = NULL,
28 + .start_routine = tc_main
29 + },
30 + {
31 + .name = "PLUGIN[diskspace]",
32 + .config_section = CONFIG_SECTION_PLUGINS,
33 + .config_name = "diskspace",
34 + .enabled = 1,
35 + .thread = NULL,
36 + .init_routine = NULL,
37 + .start_routine = diskspace_main
38 + },
39 + {
40 + .name = "PLUGIN[proc]",
41 + .config_section = CONFIG_SECTION_PLUGINS,
42 + .config_name = "proc",
43 + .enabled = 1,
44 + .thread = NULL,
45 + .init_routine = NULL,
46 + .start_routine = proc_main
47 + },
48 + {
49 + .name = "PLUGIN[cgroups]",
50 + .config_section = CONFIG_SECTION_PLUGINS,
51 + .config_name = "cgroups",
52 + .enabled = 1,
53 + .thread = NULL,
54 + .init_routine = NULL,
55 + .start_routine = cgroups_main
56 + },
57 +
58 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
59 +};
60 +
61 +const struct netdata_static_thread static_threads_freebsd[] = {
62 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
63 +};
64 +
65 +const struct netdata_static_thread static_threads_macos[] = {
66 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
67 +};
68 +
69 +struct netdata_static_thread *static_threads_get() {
70 + return static_threads_concat(static_threads_common, static_threads_linux);
71 +}
daemon/static_threads_macos.c new
+31
@@ -0,0 +1,31 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "common.h"
4 +
5 +extern void *macos_main(void *ptr);
6 +
7 +const struct netdata_static_thread static_threads_macos[] = {
8 + {
9 + .name = "PLUGIN[macos]",
10 + .config_section = CONFIG_SECTION_PLUGINS,
11 + .config_name = "macos",
12 + .enabled = 1,
13 + .thread = NULL,
14 + .init_routine = NULL,
15 + .start_routine = macos_main
16 + },
17 +
18 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
19 +};
20 +
21 +const struct netdata_static_thread static_threads_freebsd[] = {
22 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
23 +};
24 +
25 +const struct netdata_static_thread static_threads_linux[] = {
26 + {NULL, NULL, NULL, 0, NULL, NULL, NULL}
27 +};
28 +
29 +struct netdata_static_thread *static_threads_get() {
30 + return static_threads_concat(static_threads_common, static_threads_macos);
31 +}
health/health.h
-12
@@ -5,17 +5,6 @@
5
6 #include "daemon/common.h"
7
8 -#define NETDATA_PLUGIN_HOOK_HEALTH \
9 - { \
10 - .name = "HEALTH", \
11 - .config_section = NULL, \
12 - .config_name = NULL, \
13 - .enabled = 1, \
14 - .thread = NULL, \
15 - .init_routine = NULL, \
16 - .start_routine = health_main \
17 - },
18 -
8 extern unsigned int default_health_enabled;
9
10 #define HEALTH_ENTRY_FLAG_PROCESSED 0x00000001
@@ -43,7 +32,6 @@ extern unsigned int default_health_enabled;
32 extern char *silencers_filename;
33
34 extern void health_init(void);
46 -extern void *health_main(void *ptr);
35
36 extern void health_reload(void);
37
libnetdata/libnetdata.c
-1
@@ -14,7 +14,6 @@ struct rlimit rlimit_nofile = { .rlim_cur = 1024, .rlim_max = 1024 };
14 int enable_ksm = 1;
15
16 volatile sig_atomic_t netdata_exit = 0;
17 -const char *os_type = NETDATA_OS_TYPE;
17 const char *program_version = VERSION;
18
19 // ----------------------------------------------------------------------------
libnetdata/libnetdata.h
-1
@@ -274,7 +274,6 @@ extern int verify_netdata_host_prefix();
274 extern int recursively_delete_dir(const char *path, const char *reason);
275
276 extern volatile sig_atomic_t netdata_exit;
277 -extern const char *os_type;
277
278 extern const char *program_version;
279
libnetdata/os.c
+16 -3
@@ -123,7 +123,9 @@ void get_system_HZ(void) {
123 // =====================================================================================================================
124 // FreeBSD
125
126 -#if (TARGET_OS == OS_FREEBSD)
126 +#if __FreeBSD__
127 +
128 +const char *os_type = "freebsd";
129
130 int getsysctl_by_name(const char *name, void *ptr, size_t len) {
131 size_t nlen = len;
@@ -198,7 +200,9 @@ int getsysctl_mib(const char *name, int *mib, size_t len) {
200 // =====================================================================================================================
201 // MacOS
202
201 -#if (TARGET_OS == OS_MACOS)
203 +#if __APPLE__
204 +
205 +const char *os_type = "macos";
206
207 int getsysctl_by_name(const char *name, void *ptr, size_t len) {
208 size_t nlen = len;
@@ -214,4 +218,13 @@ int getsysctl_by_name(const char *name, void *ptr, size_t len) {
218 return 0;
219 }
220
217 -#endif // (TARGET_OS == OS_MACOS)
221 +#endif
222 +
223 +// =====================================================================================================================
224 +// Linux
225 +
226 +#if __linux__
227 +
228 +const char *os_type = "linux";
229 +
230 +#endif
libnetdata/os.h
+6 -16
@@ -5,16 +5,10 @@
5
6 #include "libnetdata.h"
7
8 -// =====================================================================================================================
9 -// Linux
10 -
11 -#if (TARGET_OS == OS_LINUX)
12 -
13 -
8 // =====================================================================================================================
9 // FreeBSD
10
17 -#elif (TARGET_OS == OS_FREEBSD)
11 +#if __FreeBSD__
12
13 #include <sys/sysctl.h>
14
@@ -35,28 +29,24 @@ extern int getsysctl_simple(const char *name, int *mib, size_t miblen, void *ptr
29
30 extern int getsysctl(const char *name, int *mib, size_t miblen, void *ptr, size_t *len);
31
32 +#endif
33
34 // =====================================================================================================================
35 // MacOS
36
42 -#elif (TARGET_OS == OS_MACOS)
37 +#if __APPLE__
38
39 #include <sys/sysctl.h>
40
41 #define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var))
42 extern int getsysctl_by_name(const char *name, void *ptr, size_t len);
43
49 -
50 -// =====================================================================================================================
51 -// unknown O/S
52 -
53 -#else
54 -#error unsupported operating system
44 #endif
45
57 -
46 // =====================================================================================================================
59 -// common for all O/S
47 +// common defs for Apple/FreeBSD/Linux
48 +
49 +extern const char *os_type;
50
51 extern int processors;
52 extern long get_system_cpus(void);
tests/profile/Makefile
+1 -1
@@ -1,6 +1,6 @@
1 # SPDX-License-Identifier: GPL-3.0-or-later
2
3 -COMMON_CFLAGS = -I ../../ -DTARGET_OS=1 -Wall -Wextra
3 +COMMON_CFLAGS = -I ../../ -Wall -Wextra
4 PROFILE_CFLAGS = -O1 -ggdb $(COMMON_CFLAGS)
5 PERFORMANCE_CFLAGS = -O2 $(COMMON_CFLAGS)
6