From edeb82fac99246b7d572744fe1d732fd6d9cb34e Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Mon, 18 May 2020 21:03:32 -0400 Subject: 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 Co-authored-by: James Mills --- packaging/installer/check-kernel-config.sh | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 packaging/installer/check-kernel-config.sh (limited to 'packaging/installer') diff --git a/packaging/installer/check-kernel-config.sh b/packaging/installer/check-kernel-config.sh new file mode 100755 index 0000000000..ded3225779 --- /dev/null +++ b/packaging/installer/check-kernel-config.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +get_kernel_version() { + r="$(uname -r | cut -f 1 -d '-')" + + read -r -a p <<< "$(echo "${r}" | tr '.' ' ')" + + printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}" +} + +get_rh_version() { + if [ ! -f /etc/redhat-release ]; then + printf "000000000" + return + fi + + r="$(cut -f 4 -d ' ' < /etc/redhat-release)" + + read -r -a p <<< "$(echo "${r}" | tr '.' ' ')" + + printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}" +} + +if [ "$(uname -s)" != "Linux" ]; then + echo >&2 "This does not appear to be a Linux system." + exit 1 +fi + +KERNEL_VERSION="$(uname -r)" + +if [ "$(get_kernel_version)" -lt 004014000 ] && [ "$(get_rh_version)" -lt 0070061810 ]; then + echo >&2 "WARNING: Your kernel appears to be older than 4.11 or you are using RH version older than 7.6.1810. This may still work in some cases, but probably won't." +fi + +CONFIG_PATH="" +MODULE_LOADED="" + +if modprobe configs 2> /dev/null; then + MODULE_LOADED=1 +fi + +if [ -r /proc/config.gz ]; then + CONFIG_PATH="/proc/config.gz" +elif [ -r "/lib/modules/${KERNEL_VERSION}/source/.config" ]; then + CONFIG_PATH="/lib/modules/${KERNEL_VERSION}/source/.config" +elif [ -r "/lib/modules/${KERNEL_VERSION}.x86_64/source/.config" ]; then + CONFIG_PATH="/lib/modules/${KERNEL_VERSION}.x86_64/source/.config" +elif [ -n "$(find /boot -name "config-${KERNEL_VERSION}*")" ]; then + CONFIG_PATH="$(find /boot -name "config-${KERNEL_VERSION}*" | head -n 1)" +fi + +if [ -n "${CONFIG_PATH}" ]; then + GREP='grep' + + if echo "${CONFIG_PATH}" | grep -q '.gz'; then + GREP='zgrep' + fi + + REQUIRED_CONFIG="KPROBES KPROBES_ON_FTRACE HAVE_KPROBES BPF BPF_SYSCALL BPF_JIT" + + for required_config in ${REQUIRED_CONFIG}; do + if ! "${GREP}" -q "CONFIG_${required_config}=y" "${CONFIG_PATH}"; then + echo >&2 " Missing Kernel Config: ${required_config}" + exit 1 + fi + done +fi + +if [ -n "${MODULE_LOADED}" ]; then + modprobe -r configs 2> /dev/null || true # Ignore failures from CONFIGS being builtin +fi + +exit 0 -- cgit v1.2.3