Está atualmente a visualizar o Portugal versão do sítio.
Gostaria de mudar para o seu sítio local?
14 TEMPO DE LEITURA MIN

EBPF

Using eBPF to monitor filesystems

Mihalis Tsoukalos explains how to use eBPF to track filesystems.

Part Four!

Don’t miss next issue, subscribe on page 16!

When we talk about using eBPF for tracing filesystems, we are not dealing with file I/O W (see LXF296) operations but with files as whole entities and filesystem operations. Additionally, for the first time in this series, we are going to develop our own tools using BCC Python and Go. But first, we are going to discuss the way eBPF works in more depth.

OUR EXPERT

Mihalis Tsoukalos is a systems engineer and a technical writer. He is the author of Go Systems Programming and Mastering Go, 3rd edition. You can reach him at www. mtsoukalos.eu and @mactsouk.

More about eBPF

You can consider eBPF a virtual machine located inside the Linux kernel that can execute eBPF commands, which is custom BPF code. It makes the Linux kernel programmable to help you solve real-world problems. Bear in mind that eBPF, like all languages, doesn’t solve problems on its own, it just gives you the tools to solve them. These eBPF programs are executed by the Linux kernel eBPF runtime.

EBPF software can be programmed in BCC, Bpftrace or using LLVM. The LLVM compiler can compile BPF programs into BPF bytecode using a supported programming language, such as C or the LLVM Intermediate Representation. As both ways are difficult to program because of the use of pretty low level code, BCC or Bpftrace make things simpler.

QUICK TIP

You can find all the presentations from eBPF Summit 2021, day one, at https:// youtu.be/ Kp3PHPuFkaA. Similarly, you can find all the presentations from day two of eBPF Summit 2021 at https:// youtu.be/ ZNtVedFsD-k.

When working with eBPF, begin by thinking like a system administrator, not as a programmer. Put simply, start by trying the existing eBPF tools instead of writing your own. However, if you have an issue that can’t be solved by existing tools, you might need to start acting like a developer. Other reasons for thinking like a developer include the desire to learn the eBPF internals, creating a commercial or open source project based on eBPF, doing low-level stuff like networking and security, and debugging existing code and tools.

As you become more educated and proficient in eBPF, it might be time to learn how to write new tools. Therefore, the next two sections show how to develop eBPF tools in BCC Python and Go. Both examples are relatively easy yet fully functional and practical.

Creating a new tool

Let’s write a small eBPF tool using BCC and Python, and explain what is happening. Although we are using a Python script to put our code, most of it is going to be written in C, a common practice with BCC Python. You can create your tools step by step. For example you can print a message on screen using bpf_trace_printk() when the desired event is found before handling the event. Building tools in small stages enables you to have versions that compile and run all the time, which is good when learning new technologies.

Desbloqueie este artigo e muito mais com
Pode desfrutar:
Desfrute desta edição na íntegra
Acesso instantâneo a mais de 600 títulos
Milhares de edições anteriores
Sem contrato ou compromisso
INSCREVA-SE AGORA
30 dias de teste, depois apenas €11,99 / mês. Cancelar em qualquer altura. Apenas para novos subscritores.


Saiba mais
Pocketmags Plus
Pocketmags Plus

Este artigo é de...


View Issues
Linux Format
January 2023
VER NA LOJA

Outros artigos desta edição


WELCOME
MEET THE TEAM
This issue, we’re helping people escape Windows again and use Elementary OS instead. What would you suggest a newbie should try out in the open source world?
It just works!
It’s a phrase I’ve seen used steadily for
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: Funding programmes Google’s secure OS Godot goes independent Torvalds interview Arm case aids RISC-V
Kernel Watch
Jon Masters keeps an eye out for all the latest happenings in the Linux kernel, so you don’t have to.
ONGOING DEVELOPMENT
The Asahi Linux project posted a lengthy update
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
Hmm, MX Linux has been the number one
A Photo Tool Libre
Version: 1.0.4-3 Web: https://github.com/ aphototool/A-Photo-Tool-Libre Many desktop distributions
Shutter Encoder
MULTIMEDIA CONVERTER
Passy
OFFLINE PASSWORD MANAGER
Open-Typer
TYPING TUTOR
Qtexttospeech
TEXT TO SPEECH
Thorium
WEB BROWSER
Ásbrú Connection Manager
SESSION MANAGER
ET: Legacy
FIRST-PERSON SHOOTER
Cro-Mag Rally
RACING GAME
Nvtop
GPU PROCESS MONITOR
Stretchly
BREAK REMINDER
LINUX FORMAT
The #1 open source mag Future Publishing Limited,
REVIEWS
Samsung 990 Pro 2TB
Return of the king? Yes, Jeremy Laird is back.
Phrozen Sonic 8K
Bigger prints, finer details, Linux support – is
AntiX-22
Nate Drake discovers there’s lots to love about the fast, lightweight and stable operating system that is AntiX.
Voyager Live 22.10
Nate Drake explores the glorious union of Gnome and Xfce in a single OS. You’ll never look at your desktop the same way again.
Ubuntu Unity 22.10
Nate Drake takes you on a trip down memory lane as the Unity Desktop makes its official comeback to Ubuntu.
ROUNDUP
ROUNDUP
Trilium 0.56 CherryTree 0.99 Zim 0.75 Joplin 2.8.8 QOwnNotes 22.10.3
ESCAPE WINDOWS
Looking for a practical alternative to Windows? Nick Peers reveals how to set up and use the extremely user-friendly Elementary OS.
You’ve made your choice – it’s time to install Linux alongside Windows.
Install Elementary OS alongside Windows
Take the desktop tour
The big selling point of Elementary OS is its desktop – here’s what you need to know.
Installing new apps
Finding and installing apps in Elementary OS is easy, but you’ll need more than the default app store provided.
Take a deeper dive
Your new operating system is up and running, and your journey into Linux has begun. Here’s where to focus your efforts next.
Pi USER
TWEET DREAMS ARE MADE OF THIS
Les Pounder is an editor at Tom’s Hardware
Pis to be fully stocked by autumn 2023
Eben Upton tells us we can expect shelves to be groaning with Raspberry Pis again later in 2023.
3, 2, 1, Make!
More projects!
EsPiFF
A new microcontroller.
PiKISS v1.10.0
Les Pounder is getting to an age where things need to be simple, so when someone said “Keep It Simple, Stupid”, he took no offence.
Build your own bespoke USB device
Les Pounder uses his snake charming skills again to prove how easy it is to make USB devices with Python and the cheapest of Pis.
Design and build your dream Pi robot
In his latest series, Les Pounder explains how to plan, design and build your very own Raspberry Pi robot from the basics up.
Monitor and graph your system metrics
Graphs make Matt Holder happy, so he spent his weekend storing system statistics in a database and pumping out graphs so you can, too!
The Audacity of it
We chat with Martin Keary about the new features of Audacity, managing a community and the pitfalls of telemetry.
TUTORIALS
Improve your typing
Years ago, when Shashank Sharma had more hair on his scalp than cheeks, he decided to master touch-typing. With these tools, so can you.
Take full control of your passwords
Nick Peers reveals how to get started with Buttercup, a password manager that puts you firmly in control of your sensitive data.
ReactOS: the open source Windows
Open source OS
Create videos from time-lapse photos
Time-lapse videos
Explore a box full of distributions
Containers
Get started photo editing with GIMP
Photo editing
IN DEPTH
Open source RAW photography
Linux offers all the pro-level tools you could possibly need for better photos. Karsten Günther is your top-tips guide.
CODING ACADEMY
Code an admin back-end in Django
Continuing with our magazine cataloguing application, Matt Holder explains how to create admin controls and basic view functions
Conversa
X
Suporte Pocketmags