Intelligente Lösungen
in neuer Dimension

BPFTRACE unter Ubuntu-20.04 und 22.04

Ich würde gerne BPFTRACE für die Systemüberwachung einsetzen. Leider stellt sich heraus, dass Ubuntu-20.04 und 22.04 veraltete Versionen von diesem Werkzeug ausliefern. Dadurch funktionieren viele Beispiele nicht.

Der Artikel ist leider Schrott. Nachdem ich eine Weile an der Paketerzeugung hängen geblieben bin, habe ich diese übersprungen und mit vorgefertigten Paketen herumgespielt. Dabei stellt sich heraus, dass BPFTRACE für meinen Einsatzzweck zu viele Einschränkungen aufweist und eher ungeeignet ist. Dementsprechend lohnt sich der nun doch etwas höhere Aufwand zur Paketerzeugung für mich nicht. ABGEBROCHEN!

Paket erzeugen

Ubuntu-Binary via Docker

Standard-Dockerfile

1
docker build -f docker/Dockerfile.ubuntu .

Hierbei kommt ein Binary heraus, welches unter Ubuntu-20.04 nicht lauffähig ist!

Focal-Dockerfile

1
2
3
cp docker/Dockerfile.ubuntu docker/Dockerfile.focal
sed -i -e "s/ubuntu:devel/ubuntu:focal/" docker/Dockerfile.focal
docker build -f docker/Dockerfile.focal .

Hierbei werden sehr viele Warnungen generiert! Es wird kein Binary erzeugt!

Debian-Dateien

Kopiert von debian – bpftrace:

  • build.sh
  • build-docker-image.sh
  • build-release.sh
  • docker/Dockerfile.focal
  • docker/build.sh
  • build-libs.sh

Zusätzlich:

  • git clone https://github.com/libbpf/libbpf.git
  • git clone https://github.com/iovisor/bcc

Nun Build starten mit ./build.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$ ./build.sh
~/git/forked/bpftrace/docker ~/git/forked/bpftrace
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  14.34kB
Step 1/15 : FROM ubuntu:focal
 ---> f78909c2b360
Step 2/15 : ARG LLVM_VERSION
 ---> Using cache
 ---> 4abeb06a906c
...
-- Set runtime path of "/home/uli/git/forked/bpftrace/build-release-focal/build-libs/lib64/libbcc_bpf.so.0.29.1" to ""
-- Installing: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/lib64/libbcc_bpf.so
-- Installing: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/include/bcc/BPF.h
-- Installing: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/include/bcc/BPFTable.h
Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
-- Installing: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/share/bcc/introspection/bps
-- Set runtime path of "/home/uli/git/forked/bpftrace/build-release-focal/build-libs/share/bcc/introspection/bps" to ""
...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
error: could not lock config file //.gitconfig: Permission denied
CMake Warning at CMakeLists.txt:33 (message):
  Failed to add root source directory to safe.directory


error: could not lock config file //.gitconfig: Permission denied
CMake Warning at CMakeLists.txt:42 (message):
  Failed to add blazesym source directory to safe.directory


Submodule 'libbpf-tools/blazesym' (https://github.com/libbpf/blazesym) registered for path 'libbpf-tools/blazesym'
Cloning into '/home/uli/git/forked/bpftrace/bcc/libbpf-tools/blazesym'...
Submodule path 'libbpf-tools/blazesym': checked out 'd954f73867527dc75025802160c759d0b6a0641f'
-- Latest recognized Git tag is v0.29.1
-- Git HEAD is 9a458c0a1443d9164ac9af41e0766c340cc9e759
...
-- Looking for bcc_usdt_foreach
-- Looking for bcc_usdt_foreach - not found
CMake Error at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Please install the libbpf development package (missing: LIBBPF_LIBRARIES
  LIBBPF_INCLUDE_DIRS)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindLibBpf.cmake:32 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:83 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/uli/git/forked/bpftrace/build-release-focal/CMakeFiles/CMakeOutput.log".
See also "/home/uli/git/forked/bpftrace/build-release-focal/CMakeFiles/CMakeError.log".

Nach Erweiterung von docker/Dockerfile.focal um “python3-setuptools” gibt es diesen Fehler:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
-- Up-to-date: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/include/bcc/BPFTable.h
running install
Checking .pth file support in /home/uli/git/forked/bpftrace/build-release-focal/build-libs/lib/python3/dist-packages/
/usr/bin/python3 -E -c pass
TEST FAILED: /home/uli/git/forked/bpftrace/build-release-focal/build-libs/lib/python3/dist-packages/ does NOT support .pth files
bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/uli/git/forked/bpftrace/build-release-focal/build-libs/lib/python3/dist-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.
...

Links

Historie

  • 2023-12-30 – Erste Version