Add netdata-plugin-systemd-journal package. (#15733)
* Add netdata-plugin-systemd-journal package. * Fix suggests usage in spec file. * Skip systemd journal on old platforms in native packages. * Actually build systemd-journal plugin everywhere. * Fix spec file syntax. * Install systemd-journal plugin by default on supported systems. * Update packaging/installer/netdata-updater.sh Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud> * Explicitly mark optional plugins as auto-installed when possible. --------- Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Austin S. Hemmelgarn committed
Aug 4, 2023 at 12:22 UTC
ca1b3eebb21b8ed8510b738c7ace780b38023efe
9 files changed
+128
-70
contrib/debian/control
+13
-1
@@ -54,6 +54,7 @@ Conflicts: netdata-core,
54
netdata-web
55
Suggests: netdata-plugin-cups,
56
netdata-plugin-freeipmi
57
+Recommends: netdata-plugin-systemd-journal
58
Description: real-time charts for system monitoring
59
Netdata is a daemon that collects data in realtime (per second)
60
and presents a web site to view and analyze them. The presentation
@@ -182,10 +183,21 @@ Description: The perf metrics collector for the Netdata Agent
183
184
Package: netdata-plugin-debugfs
185
Architecture: any
185
-Depends: ${shlibs:Debends},
186
+Depends: ${shlibs:Depends},
187
netdata (= ${source:Version})
188
Pre-Depends: libcap2-bin, adduser
189
Conflicts: netdata (<< ${source:Version})
190
Description: The debugfs metrics collector for the Netdata Agent
191
This plugin allows the Netdata Agent to collect Linux kernel metrics
192
exposed through debugfs.
193
+
194
+Package: netdata-plugin-systemd-journal
195
+Architecture: any
196
+Depends: ${shlibs:Depends},
197
+ netdata (= ${source:Version})
198
+Pre-Depends: libcap2-bin, adduser
199
+Build-Depends: libsystemd-dev
200
+Conflicts: netdata (<< ${source:Version})
201
+Description: The systemd-journal collector for the Netdata Agent
202
+ This plugin allows the Netdata Agent to present logs from the systemd
203
+ journal on Netdata Cloud or the local Agent dashboard.
contrib/debian/control.xenial
deleted
-61
@@ -1,61 +0,0 @@
1
-Source: netdata
2
-Build-Depends: debhelper (>= 9),
3
- dh-autoreconf,
4
- dh-systemd (>= 1.5),
5
- dpkg-dev (>= 1.13.19),
6
- zlib1g-dev,
7
- uuid-dev,
8
- libelf-dev,
9
- libuv1-dev,
10
- liblz4-dev,
11
- libssl-dev,
12
- libmnl-dev,
13
- libjson-c-dev,
14
- libcups2-dev,
15
- libipmimonitoring-dev,
16
- libnetfilter-acct-dev,
17
- libsnappy-dev,
18
- libprotobuf-dev,
19
- libprotoc-dev,
20
- cmake,
21
- autogen,
22
- autoconf,
23
- automake,
24
- pkg-config,
25
- curl,
26
- protobuf-compiler
27
-Section: net
28
-Priority: optional
29
-Maintainer: Netdata Builder <bot@netdata.cloud>
30
-Standards-Version: 3.9.6
31
-Homepage: https://netdata.cloud
32
-
33
-Package: netdata
34
-Architecture: any
35
-Depends: adduser,
36
- libcap2-bin (>= 1:2.0),
37
- lsb-base (>= 3.1-23.2),
38
- openssl,
39
- ${misc:Depends},
40
- ${shlibs:Depends}
41
-Pre-Depends: dpkg (>= 1.17.14)
42
-Description: real-time charts for system monitoring
43
- Netdata is a daemon that collects data in realtime (per second)
44
- and presents a web site to view and analyze them. The presentation
45
- is also real-time and full of interactive charts that precisely
46
- render all collected values.
47
-
48
-Package: netdata-plugin-cups
49
-Architecture: any
50
-Depends: cups,
51
- netdata (>= ${source:Version})
52
-Description: The Common Unix Printing System plugin for metrics collection from cupsd
53
-
54
-Package: netdata-plugin-freeipmi
55
-Architecture: any
56
-Depends: freeipmi,
57
- netdata (= ${source:Version})
58
-Description: FreeIPMI - The Intelligent Platform Management System.
59
- The IPMI specification defines a set of interfaces for platform management.
60
- It is implemented by a number vendors for system management. The features of IPMI that most users will be interested in
61
- are sensor monitoring, system event monitoring, power control, and serial-over-LAN (SOL).
contrib/debian/netdata-plugin-systemd-journal.postinst
new
+14
@@ -0,0 +1,14 @@
1
+#!/bin/sh
2
+
3
+set -e
4
+
5
+case "$1" in
6
+ configure|reconfigure)
7
+ chown root:netdata /usr/libexec/netdata/plugins.d/systemd-journal.plugin
8
+ setcap "cap_dac_read_search=eip" /usr/libexec/netdata/plugins.d/systemd-journal.plugin
9
+ ;;
10
+esac
11
+
12
+#DEBHELPER#
13
+
14
+exit 0
contrib/debian/netdata-plugin-systemd-journal.preinst
new
+13
@@ -0,0 +1,13 @@
1
+#!/bin/sh
2
+
3
+set -e
4
+
5
+case "$1" in
6
+ install)
7
+ if ! getent group netdata > /dev/null; then
8
+ addgroup --quiet --system netdata
9
+ fi
10
+ ;;
11
+esac
12
+
13
+#DEBHELPER#
contrib/debian/rules
+6
-1
@@ -125,6 +125,11 @@ override_dh_install:
125
mv -f $(TEMPTOP)/usr/libexec/netdata/plugins.d/debugfs.plugin \
126
$(TOP)-plugin-debugfs/usr/libexec/netdata/plugins.d/debugfs.plugin
127
128
+ # Add systemd-journal plugin install rules
129
+ mkdir -p $(TOP)-plugin-systemd-journal/usr/libexec/netdata/plugins.d/
130
+ mv -f $(TEMPTOP)/usr/libexec/netdata/plugins.d/systemd-journal.plugin \
131
+ $(TOP)-plugin-systemd-journal/usr/libexec/netdata/plugins.d/systemd-journal.plugin; \
132
+
133
# Set the rest of the software in the main package
134
#
135
cp -rp $(TEMPTOP)/usr $(TOP)
@@ -214,7 +219,7 @@ override_dh_fixperms:
219
chmod 4750 $(TOP)/usr/libexec/netdata/plugins.d/local-listeners
220
221
# systemd-journal
217
- # chmod 4750 $(TOP)/usr/libexec/netdata/plugins.d/systemd-journal.plugin
222
+ chmod 4750 $(TOP)-plugin-systemd-journal/usr/libexec/netdata/plugins.d/systemd-journal.plugin
223
224
override_dh_installlogrotate:
225
cp system/logrotate/netdata debian/netdata.logrotate
netdata.spec.in
+41
-6
@@ -158,13 +158,14 @@ Requires: netdata-plugin-chartsd
158
Requires: netdata-plugin-slabinfo
159
Requires: netdata-plugin-perf
160
%if 0%{?_have_nfacct}
161
-Requires: netdata-plugin-nfacct
161
+Requires: netdata-plugin-nfacct
162
%endif
163
%if 0%{?_have_freeipmi} && 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2
164
-Suggests: netdata-plugin-freeipmi
164
+Suggests: netdata-plugin-freeipmi
165
%endif
166
%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2
167
-Suggests: netdata-plugin-cups
167
+Suggests: netdata-plugin-cups
168
+Recommends: netdata-plugin-systemd-journal
169
%endif
170
171
@@ -203,6 +204,10 @@ BuildRequires: cups-devel >= 1.7
204
%endif
205
# end - cups plugin dependencies
206
207
+# systemd-journal dependencies
208
+BuildRequires: systemd-devel
209
+# end - systemd-journal dependencies
210
+
211
# Prometheus remote write dependencies
212
BuildRequires: snappy-devel
213
# end - prometheus remote write dependencies
@@ -248,13 +253,13 @@ export CFLAGS="${CFLAGS} -fPIC" && ${RPM_BUILD_DIR}/%{name}-%{version}/packaging
253
autoreconf -ivf
254
%configure \
255
%if 0%{!?_have_ebpf}
251
- --disable-ebpf
256
+ --disable-ebpf \
257
%endif
258
%if 0%{!?_have_freeipmi}
254
- --disable-plugin-freeipmi
259
+ --disable-plugin-freeipmi \
260
%endif
261
%if 0%{!?_have_nfacct}
257
- --disable-plugin-nfacct
262
+ --disable-plugin-nfacct \
263
%endif
264
%if 0%{?centos_ver:1}
265
%if %{centos_ver} < 8
@@ -306,6 +311,10 @@ install -m 4750 -p apps.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.
311
# Install debugfs.plugin
312
install -m 0750 -p debugfs.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/debugfs.plugin"
313
314
+# ###########################################################
315
+# Install systemd-journal.plugin
316
+install -m 4750 -p systemd-journal.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin"
317
+
318
# ###########################################################
319
# Install perf.plugin
320
install -m 4750 -p perf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/perf.plugin"
@@ -600,6 +609,9 @@ rm -rf "${RPM_BUILD_ROOT}"
609
# perf belongs to a different sub-package
610
%exclude %{_libexecdir}/%{name}/plugins.d/perf.plugin
611
612
+# systemd-journal belongs to a different sub-package
613
+%exclude %{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin
614
+
615
# CUPS belongs to a different sub package
616
%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7
617
%exclude %{_libexecdir}/%{name}/plugins.d/cups.plugin
@@ -901,7 +913,30 @@ fi
913
# CAP_DAC_READ_SEARCH required for data collection.
914
%caps(cap_dac_read_search=ep) %attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/debugfs.plugin
915
916
+%package plugin-systemd-journal
917
+Summary: The systemd-journal plugin for the Netdata Agent
918
+Group: Applications/System
919
+Requires: netdata = %{version}
920
+Conflicts: netdata < %{version}
921
+
922
+%description plugin-systemd-journal
923
+ This plugin allows the Netdata Agent to present entries from the systemd
924
+ journal on Netdata Cloud or the local Agent Dashboard.
925
+
926
+%pre plugin-systemd-journal
927
+
928
+if ! getent group netdata > /dev/null; then
929
+ groupadd --system netdata
930
+fi
931
+
932
+%files plugin-systemd-journal
933
+%defattr(0750,root,netdata,0750)
934
+# CAP_DAC_READ_SEARCH required for data collection.
935
+%caps(cap_dac_read_search=ep) %attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin
936
+
937
%changelog
938
+* Thu Aug 03 2023 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-21
939
+- Added systemd-journal plugin handling
940
* Wed Jun 14 2023 Konstantin Shalygin <k0ste@k0ste.ru> 0.0.0-20
941
- Added eBPF build dependency (again)
942
* Fri Apr 07 2023 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-19
packaging/installer/UPDATE.md
+3
@@ -182,3 +182,6 @@ The following configuration options are currently supported:
182
as a scheduled task. This random delay helps avoid issues resulting from too many nodes trying to reconnect to
183
the Cloud at the same time. The default value is 3600, which corresponds to one hour. Most users should not ever
184
need to change this.
185
+- `NETDATA_NO_SYSTEMD_JOURNAL`: If set to a value other than 0, skip attempting to install the
186
+ `netdata-plugin-systemd-journal` package on supported systems on update. This optional package will be installed
187
+ by default on supported systems by the updater if this option is not set. Only affects systems using native packages.
packaging/installer/netdata-updater.sh
+24
-1
@@ -37,7 +37,9 @@ PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packag
37
NETDATA_STABLE_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata/releases}"
38
NETDATA_NIGHTLY_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata-nightlies/releases}"
39
40
+# Following variables are intended to be overridden by the updater config file.
41
NETDATA_UPDATER_JITTER=3600
42
+NETDATA_NO_SYSTEMD_JOURNAL=0
43
44
script_dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
45
@@ -758,9 +760,11 @@ update_binpkg() {
760
fi
761
pm_cmd="apt-get"
762
repo_subcmd="update"
763
+ install_subcmd="install"
764
+ mark_auto_cmd="apt-mark auto"
765
pkg_install_opts="${interactive_opts}"
766
repo_update_opts="${interactive_opts}"
763
- pkg_installed_check="dpkg -s"
767
+ pkg_installed_check="dpkg-query -s"
768
INSTALL_TYPE="binpkg-deb"
769
;;
770
centos|fedora|ol|amzn)
@@ -770,10 +774,13 @@ update_binpkg() {
774
if command -v dnf > /dev/null; then
775
pm_cmd="dnf"
776
repo_subcmd="makecache"
777
+ mark_auto_cmd="dnf mark remove"
778
else
779
pm_cmd="yum"
780
+ mark_auto_cmd="yumdb set reason dep"
781
fi
782
upgrade_subcmd="upgrade"
783
+ install_subcmd="install"
784
pkg_install_opts="${interactive_opts}"
785
repo_update_opts="${interactive_opts}"
786
pkg_installed_check="rpm -q"
@@ -787,6 +794,8 @@ update_binpkg() {
794
fi
795
pm_cmd="zypper"
796
repo_subcmd="--gpg-auto-import-keys refresh"
797
+ install_subcmd="install"
798
+ mark_auto_cmd=""
799
pkg_install_opts=""
800
repo_update_opts=""
801
pkg_installed_check="rpm -q"
@@ -816,6 +825,20 @@ update_binpkg() {
825
826
# shellcheck disable=SC2086
827
env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} netdata >&3 2>&3 || fatal "Failed to update Netdata package." U000F
828
+
829
+ if ${pkg_installed_check} systemd > /dev/null 2>&1; then
830
+ if [ "${NETDATA_NO_SYSTEMD_JOURNAL}" -eq 0 ]; then
831
+ if ! ${pkg_installed_check} netdata-plugin-systemd-journal > /dev/null 2>&1; then
832
+ env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} netdata-plugin-systemd-journal >&3 2>&3
833
+
834
+ if [ -n "${mark_auto_cmd}" ]; then
835
+ # shellcheck disable=SC2086
836
+ env ${env} ${mark_auto_cmd} netdata-plugin-systemd-journal >&3 2>&3
837
+ fi
838
+ fi
839
+ fi
840
+ fi
841
+
842
[ -n "${logfile}" ] && rm "${logfile}" && logfile=
843
return 0
844
}
system/netdata-updater.conf
+14
@@ -5,3 +5,17 @@
5
# actually running the update. The default is 3600 (one
6
# hour). Most users should not need to change this.
7
#NETDATA_UPDATER_JITTER="3600"
8
+
9
+# On systems using our native packages, the updater will by default
10
+# attempt to install optional plugin packages that would be installed by
11
+# default on clean installs if those packages are supported on the system.
12
+#
13
+# This behavior can be disabled on a per-package basis using the below
14
+# variables. Setting the variable to a value other than 0 will disable
15
+# the corresponding package (note that you still need to remove the package
16
+# yourself if you don0t want it, this just controls whether the updater
17
+# will try to ensure it’s installed or not).
18
+#
19
+# NETDATA_NO_SYSTEMD_JOURNAL controls the `netdata-plugin-systemd-journal`
20
+# package, which provides the systemd journal plugin for Netdata.
21
+#NETDATA_NO_SYSTEMD_JOURNAL="0"