@cryptotaxi247 / netdata / commits / 3be9c2c9c

Enable Rust-based journal file reader in static builds. (#20477)

* Enable Rust-based journal file reader in static builds. * Actually enable systemd journal plugin in static builds. * Comment out stuff not related to jf FFI * Define _GNU_SOURCE * Enable fstat caching only when not using our journal file reader. * Use crt-static target feature * Use local flags * Revert "Use local flags" This reverts commit dbad23614f81f16ac09a554d7931fedf11d32aff. * Revert "Use crt-static target feature" This reverts commit a3a9580dc5718917b7458193ed38156f50ca844f. * Use RUSTFLAGS * Do not use fstat caching when built with Rust. * Disable Rust journal file reader for ARMv6l Rust builds are somehow fundamentally broken when trying to build ARMv6 code on a 64-bit ARMv8 host, so just skip it there for now. --------- Co-authored-by: vkalintiris <vasilis@netdata.cloud>

Austin S. Hemmelgarn committed Jun 23, 2025 at 07:34 UTC 3be9c2c9c886f770a446cfebd28ddf9a1e51700f
6 files changed +48 -14
CMakeLists.txt
+1 -1
@@ -1787,12 +1787,12 @@ set(STATSD_PLUGIN_FILES
1787
1788 set(SYSTEMD_JOURNAL_PLUGIN_FILES
1789 src/collectors/systemd-journal.plugin/systemd-journal.c
1790 + src/collectors/systemd-journal.plugin/systemd-journal-fstat.c
1791 src/collectors/systemd-journal.plugin/systemd-internals.h
1792 src/collectors/systemd-journal.plugin/systemd-main.c
1793 src/collectors/systemd-journal.plugin/systemd-journal.c
1794 src/collectors/systemd-journal.plugin/systemd-journal-annotations.c
1795 src/collectors/systemd-journal.plugin/systemd-journal-files.c
1795 - src/collectors/systemd-journal.plugin/systemd-journal-fstat.c
1796 src/collectors/systemd-journal.plugin/systemd-journal-watcher.c
1797 src/collectors/systemd-journal.plugin/systemd-journal-dyncfg.c
1798 src/collectors/systemd-journal.plugin/provider/netdata_provider.c
netdata-installer.sh
+2
@@ -215,6 +215,7 @@ USAGE: ${PROGRAM} [options]
215 --disable-plugin-xenstat Explicitly disable the xenstat plugin.
216 --enable-plugin-systemd-journal Enable the systemd journal plugin. Default: enable it when libsystemd is available.
217 --disable-plugin-systemd-journal Explicitly disable the systemd journal plugin.
218 + --internal-systemd-journal Enable the internal journal file reader instead of using libsystemd
219 --enable-exporting-kinesis Enable AWS Kinesis exporting connector. Default: enable it when libaws_cpp_sdk_kinesis
220 and its dependencies are available.
221 --disable-exporting-kinesis Explicitly disable AWS Kinesis exporting connector.
@@ -294,6 +295,7 @@ while [ -n "${1}" ]; do
295 "--disable-plugin-xenstat") ENABLE_XENSTAT=0 ;;
296 "--enable-plugin-systemd-journal") ENABLE_SYSTEMD_JOURNAL=1 ;;
297 "--disable-plugin-systemd-journal") ENABLE_SYSTEMD_JOURNAL=0 ;;
298 + "--internal-systemd-journal") USE_RUST_JOURNAL_FILE=1 ;;
299 "--enable-exporting-kinesis" | "--enable-backend-kinesis")
300 # TODO: Needs CMake Support
301 ;;
packaging/installer/functions.sh
+13 -7
@@ -330,19 +330,25 @@ prepare_cmake_options() {
330 fi
331
332 if [ -z "${ENABLE_SYSTEMD_JOURNAL}" ]; then
333 - if check_for_module libsystemd; then
334 - if check_for_module libelogind; then
335 - ENABLE_SYSTEMD_JOURNAL=0
336 - else
337 - ENABLE_SYSTEMD_JOURNAL=1
338 - fi
333 + if check_for_module libsystemd; then
334 + if check_for_module libelogind; then
335 + ENABLE_SYSTEMD_JOURNAL=0
336 else
340 - ENABLE_SYSTEMD_JOURNAL=0
337 + ENABLE_SYSTEMD_JOURNAL=1
338 fi
339 + else
340 + ENABLE_SYSTEMD_JOURNAL=0
341 + fi
342 fi
343
344 enable_feature PLUGIN_SYSTEMD_JOURNAL "${ENABLE_SYSTEMD_JOURNAL}"
345
346 + if [ "${ENABLE_SYSTEMD_JOURNAL}" -eq 1 ] && [ -n "${USE_RUST_JOURNAL_FILE}" ]; then
347 + enable_feature NETDATA_JOURNAL_FILE_READER 1
348 + else
349 + enable_feature NETDATA_JOURNAL_FILE_READER 0
350 + fi
351 +
352 if check_for_module 'libsystemd >= 221'; then
353 enable_feature PLUGIN_SYSTEMD_UNITS 1
354 else
packaging/makeself/jobs/70-netdata-git.install.sh
+12 -1
@@ -27,15 +27,26 @@ NETDATA_BUILD_DIR="$(build_path netdata)"
27 export NETDATA_BUILD_DIR
28
29 case "${BUILDARCH}" in
30 - *) export NETDATA_CMAKE_OPTIONS="-DENABLE_LIBBACKTRACE=On"
30 + armv6l)
31 + export NETDATA_CMAKE_OPTIONS="-DENABLE_LIBBACKTRACE=On"
32 + export INSTALLER_ARGS="--disable-plugin-systemd-journal"
33 + ;;
34 + *)
35 + export NETDATA_CMAKE_OPTIONS="-DENABLE_LIBBACKTRACE=On"
36 + export INSTALLER_ARGS="--enable-plugin-systemd-journal --internal-systemd-journal"
37 + ;;
38 esac
39
40 +export RUSTFLAGS="-C target-feature=+crt-static"
41 +
42 run ./netdata-installer.sh \
43 --install-prefix "${NETDATA_INSTALL_PARENT}" \
44 --dont-wait \
45 --dont-start-it \
46 --disable-exporting-mongodb \
47 + --enable-plugin-systemd-journal \
48 --dont-scrub-cflags-even-though-it-may-break-things \
49 --one-time-build \
50 --enable-lto \
51 + ${INSTALLER_ARGS:+${INSTALLER_ARGS}} \
52 ${EXTRA_INSTALL_FLAGS:+${EXTRA_INSTALL_FLAGS}} \
src/collectors/systemd-journal.plugin/systemd-journal-fstat.c
+15
@@ -2,6 +2,8 @@
2
3 #include "systemd-internals.h"
4
5 +#if !defined(HAVE_RUST_PROVIDER)
6 +
7 // ----------------------------------------------------------------------------
8 // fstat64 overloading to speed up libsystemd
9 // https://github.com/systemd/systemd/pull/29261
@@ -76,3 +78,16 @@ int fstat64(int fd, struct stat64 *buf)
78
79 return ret;
80 }
81 +
82 +#else // HAVE_RUST_PROVIDER
83 +
84 +// When using Rust provider, disable fstat caching entirely since
85 +// we will not rely on libsystemd.
86 +
87 +__thread size_t fstat_thread_calls = 0;
88 +__thread size_t fstat_thread_cached_responses = 0;
89 +
90 +void fstat_cache_enable_on_thread(void) { }
91 +void fstat_cache_disable_on_thread(void) { }
92 +
93 +#endif
src/crates/jf/Cargo.toml
+5 -5
@@ -2,13 +2,13 @@
2 resolver = "2"
3 members = [
4 "error",
5 - "main",
5 + # "main",
6 "journal_file",
7 - "journal_writer",
7 + # "journal_writer",
8 "journal_reader",
9 "journal_reader_ffi",
10 - "journal_logger",
11 - "journal_forwarder",
10 + # "journal_logger",
11 + # "journal_forwarder",
12 "window_manager",
13 "sigbus",
14 ]
@@ -29,7 +29,7 @@ duct = "0.13"
29 serde_json = "1.0"
30 walkdir = "2"
31 ruzstd = "0.8"
32 -systemd = { path = "/home/vk/repos/crates/rust-systemd"}
32 +# systemd = { path = "/home/vk/repos/crates/rust-systemd"}
33 libc = "0.2"
34
35 [profile.release]