summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2020-05-18 21:03:32 -0400
committerGitHub <noreply@github.com>2020-05-19 11:03:32 +1000
commitedeb82fac99246b7d572744fe1d732fd6d9cb34e (patch)
tree244bf54702edd4f96cc03b974a0174761a1436c9 /libnetdata
parent3cf541f25558ef3b2f43b4bc857e64042a2d09e5 (diff)
install and enable eBPF Plugin by default (#8665)
* netdata_installer_kernels: New kernels This commit brings new kernels for our netdata-installer * RH detection This commit brings the RH detection to netdata-installer, but it cannot be tested yet until we merge a PR on kernel-collector * netdata_installer_kernels: RH kernels This commit brings updates that allows to install and run the collectors on RH * netdata_installer_kernels: Kernel variables This commit brings definitions instead magic number to the isntaller * netdata_installer_kernels: remove echo This commit removes echo to avoid new line * netdata_installer_kernels: Move C code This commit removes the C code that will be inserted in another PR * Update eBPF install to use released version. This updates the install code for the eBPF plugin to properly utilize (and verify) a tagged release of the plugin instead of pulling the upstream master branch. It also adds support for using a local copy of the tarball, and switchs the default behavior to install the eBPF plugin instead of not installing it. * Tidy-up messages relating to eBPF. * Fix typos in error handling functions. * ebpf-release: New kernels This commit brings the kernels necessary to support Debian 10.0 * ebpf-release: Bring support for new package format * ebpf-release: collector as loader This commit brings the necessary changes for the collector loads all the nfiles depending of the kernel it is running * Update eBPF install to use released version. This updates the install code for the eBPF plugin to properly utilize (and verify) a tagged release of the plugin instead of pulling the upstream master branch. It also adds support for using a local copy of the tarball, and switchs the default behavior to install the eBPF plugin instead of not installing it. * netdata_installer_kernels: New kernels This commit brings new kernels for our netdata-installer * RH detection This commit brings the RH detection to netdata-installer, but it cannot be tested yet until we merge a PR on kernel-collector * netdata_installer_kernels: RH kernels This commit brings updates that allows to install and run the collectors on RH * netdata_installer_kernels: Kernel variables This commit brings definitions instead magic number to the isntaller * netdata_installer_kernels: remove echo This commit removes echo to avoid new line * netdata_installer_kernels: Move C code This commit removes the C code that will be inserted in another PR * Tidy-up messages relating to eBPF. * Fix typos in error handling functions. * ebpf-release: New kernels This commit brings the kernels necessary to support Debian 10.0 * ebpf-release: Bring support for new package format * ebpf-release: collector as loader This commit brings the necessary changes for the collector loads all the nfiles depending of the kernel it is running * Fix package name handling. * Bump eBPF kernel-collector to v0.1.0 * Update --help to state eBPF is enabled by default and add --disable-ebpf option in --help output * Remove deprecated kernel version compatibility checks * Fix EBPF_TARBALL * Remove libc path detection logic (deprecated0 * Use the new package structure of kernel-collector * Relax the glob on netdata_ebpf as we may develop/distirbute other types of ebpf programs * Fix ownership of ebpf libraries/programs * Make the check-kernel-config.sh local to the installer * Make plugins.ebpf = yes (by default) Co-authored-by: Thiago Marques <thiagoftsm@gmail.com> Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/ebpf/ebpf.c27
-rw-r--r--libnetdata/ebpf/ebpf.h23
2 files changed, 48 insertions, 2 deletions
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c
index ea1fc37e1b..3ab36a4fa3 100644
--- a/libnetdata/ebpf/ebpf.c
+++ b/libnetdata/ebpf/ebpf.c
@@ -53,11 +53,12 @@ int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr) {
//----------------------------------------------------------------------------------------------------------------------
-int get_kernel_version() {
+int get_kernel_version(char *out, int size) {
char major[16], minor[16], patch[16];
char ver[256];
char *version = ver;
+ out[0] = '\0';
int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
if (fd < 0)
return -1;
@@ -88,6 +89,10 @@ int get_kernel_version() {
while (*version) *move++ = *version++;
*move = '\0';
+ fd = snprintf(out, (size_t)size, "%s.%s.%s", major, minor, patch);
+ if (fd > size)
+ error("[EBPF]: The buffer to store kernel version is not smaller than necessary.");
+
return ((int)(str2l(major)*65536) + (int)(str2l(minor)*256) + (int)str2l(patch));
}
@@ -143,3 +148,23 @@ int has_condition_to_run(int version) {
return 1;
}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+char *ebpf_library_suffix(int version, int isrh) {
+ if (isrh) {
+ if (version >= NETDATA_EBPF_KERNEL_4_11)
+ return "4.18.0";
+ else
+ return "3.10.0";
+ } else {
+ if (version >= NETDATA_EBPF_KERNEL_4_17)
+ return "5.4.20";
+ else if (version >= NETDATA_EBPF_KERNEL_4_15)
+ return "4.16.18";
+ else if (version >= NETDATA_EBPF_KERNEL_4_11)
+ return "4.14.171";
+ }
+
+ return NULL;
+}
diff --git a/libnetdata/ebpf/ebpf.h b/libnetdata/ebpf/ebpf.h
index e7cd651a67..d4fa138c56 100644
--- a/libnetdata/ebpf/ebpf.h
+++ b/libnetdata/ebpf/ebpf.h
@@ -26,6 +26,26 @@
*/
# define NETDATA_RH_8 2048
+/**
+ * Kernel 4.17
+ *
+ * 266496 = 4*65536 + 17*256
+ */
+# define NETDATA_EBPF_KERNEL_4_17 266496
+
+/**
+ * Kernel 4.15
+ *
+ * 265984 = 4*65536 + 15*256
+ */
+# define NETDATA_EBPF_KERNEL_4_15 265984
+
+/**
+ * Kernel 4.11
+ *
+ * 264960 = 4*65536 + 15*256
+ */
+# define NETDATA_EBPF_KERNEL_4_11 264960
typedef struct netdata_ebpf_events {
char type;
@@ -34,8 +54,9 @@ typedef struct netdata_ebpf_events {
} netdata_ebpf_events_t;
extern int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr);
-extern int get_kernel_version();
+extern int get_kernel_version(char *out, int size);
extern int get_redhat_release();
extern int has_condition_to_run(int version);
+extern char *ebpf_library_suffix(int version, int isrh);
#endif