Collect TCP metrics and send to InfluxDB
Go to file
2024-07-12 17:37:06 +02:00
tests First commit 2024-07-12 17:37:06 +02:00
.gitignore First commit 2024-07-12 17:37:06 +02:00
common.h First commit 2024-07-12 17:37:06 +02:00
exec.sh First commit 2024-07-12 17:37:06 +02:00
ic.c First commit 2024-07-12 17:37:06 +02:00
ic.h First commit 2024-07-12 17:37:06 +02:00
load_bpf.c First commit 2024-07-12 17:37:06 +02:00
README.md First commit 2024-07-12 17:37:06 +02:00
tcp_server.py First commit 2024-07-12 17:37:06 +02:00
tp_tcp.c First commit 2024-07-12 17:37:06 +02:00
vmlinux.h First commit 2024-07-12 17:37:06 +02:00

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