tcp_metrics/README.md
2024-07-12 17:37:06 +02:00

1.2 KiB

Introduction

This project collect some metrics for TCP. For doing that, I use eBPF.

Requirements

For executing and loading the eBPF program and to send data to InfluxDB, you need to install some packages:

sudo apt install linux-headers-`uname -r` clang-11 gcc gcc-multilib libbpf-dev libbpfcc bpfcc-tools

For installing bpftool command:

sudo apt install linux-tools-common linux-tools-generic

Compile eBPF program

First, you need to dump the vmlinux header file, which contains all definitions codes of your Linux kernel:

sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h

After that, you can compile the eBPF code:

$ clang-11 -g -O2 -target bpf -c tp_tcp.c -o tp_tcp.o

Now, I made a C script which can load the eBPF program and attach it:

$ gcc load_bpf.c -o load_bpf -lbpf

And you can execute it, but, you need to have the root privileges:

$ sudo ./load_bpf

InfluxDB

I use this project for sending data to InfluxDB.

The documentation of that project is here