How To Install bpftrace on CentOS 8

bpftrace is High-level tracing language for Linux eBPF

Introduction

In this tutorial we learn how to install bpftrace on CentOS 8.

What is bpftrace

BPFtrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x). BPFtrace uses LLVM as a backend to compile scripts to BPF-bytecode and makes use of BCC for interacting with the Linux BPF system, as well as existing Linux tracing capabilities (uprobes), and tracepoints. The BPFtrace language is inspired by awk and C, and predecessor tracers such as DTrace and SystemTap

We can use yum or dnf to install bpftrace on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install bpftrace.

Install bpftrace on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install bpftrace using dnf by running the following command:

sudo dnf -y install bpftrace

Install bpftrace on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install bpftrace using yum by running the following command:

sudo yum -y install bpftrace

How To Uninstall bpftrace on CentOS 8

To uninstall only the bpftrace package we can use the following command:

sudo dnf remove bpftrace

bpftrace Package Contents on CentOS 8

/usr/bin/bpftrace
/usr/lib/.build-id
/usr/lib/.build-id/11
/usr/lib/.build-id/11/d5476318244496f5e43e87ea62fb5773e0b8b1
/usr/share/bpftrace
/usr/share/bpftrace/tools
/usr/share/bpftrace/tools/bashreadline.bt
/usr/share/bpftrace/tools/biolatency.bt
/usr/share/bpftrace/tools/biosnoop.bt
/usr/share/bpftrace/tools/biostacks.bt
/usr/share/bpftrace/tools/bitesize.bt
/usr/share/bpftrace/tools/capable.bt
/usr/share/bpftrace/tools/cpuwalk.bt
/usr/share/bpftrace/tools/dcsnoop.bt
/usr/share/bpftrace/tools/doc
/usr/share/bpftrace/tools/doc/bashreadline_example.txt
/usr/share/bpftrace/tools/doc/biolatency_example.txt
/usr/share/bpftrace/tools/doc/biosnoop_example.txt
/usr/share/bpftrace/tools/doc/biostacks_example.txt
/usr/share/bpftrace/tools/doc/bitesize_example.txt
/usr/share/bpftrace/tools/doc/capable_example.txt
/usr/share/bpftrace/tools/doc/cpuwalk_example.txt
/usr/share/bpftrace/tools/doc/dcsnoop_example.txt
/usr/share/bpftrace/tools/doc/execsnoop_example.txt
/usr/share/bpftrace/tools/doc/gethostlatency_example.txt
/usr/share/bpftrace/tools/doc/killsnoop_example.txt
/usr/share/bpftrace/tools/doc/loads_example.txt
/usr/share/bpftrace/tools/doc/mdflush_example.txt
/usr/share/bpftrace/tools/doc/naptime_example.txt
/usr/share/bpftrace/tools/doc/oomkill_example.txt
/usr/share/bpftrace/tools/doc/opensnoop_example.txt
/usr/share/bpftrace/tools/doc/pidpersec_example.txt
/usr/share/bpftrace/tools/doc/runqlat_example.txt
/usr/share/bpftrace/tools/doc/runqlen_example.txt
/usr/share/bpftrace/tools/doc/setuids_example.txt
/usr/share/bpftrace/tools/doc/statsnoop_example.txt
/usr/share/bpftrace/tools/doc/swapin_example.txt
/usr/share/bpftrace/tools/doc/syncsnoop_example.txt
/usr/share/bpftrace/tools/doc/syscount_example.txt
/usr/share/bpftrace/tools/doc/tcpaccept_example.txt
/usr/share/bpftrace/tools/doc/tcpconnect_example.txt
/usr/share/bpftrace/tools/doc/tcpdrop_example.txt
/usr/share/bpftrace/tools/doc/tcplife_example.txt
/usr/share/bpftrace/tools/doc/tcpretrans_example.txt
/usr/share/bpftrace/tools/doc/tcpsynbl_example.txt
/usr/share/bpftrace/tools/doc/threadsnoop_example.txt
/usr/share/bpftrace/tools/doc/vfscount_example.txt
/usr/share/bpftrace/tools/doc/vfsstat_example.txt
/usr/share/bpftrace/tools/doc/writeback_example.txt
/usr/share/bpftrace/tools/doc/xfsdist_example.txt
/usr/share/bpftrace/tools/execsnoop.bt
/usr/share/bpftrace/tools/gethostlatency.bt
/usr/share/bpftrace/tools/killsnoop.bt
/usr/share/bpftrace/tools/loads.bt
/usr/share/bpftrace/tools/mdflush.bt
/usr/share/bpftrace/tools/naptime.bt
/usr/share/bpftrace/tools/oomkill.bt
/usr/share/bpftrace/tools/opensnoop.bt
/usr/share/bpftrace/tools/pidpersec.bt
/usr/share/bpftrace/tools/runqlat.bt
/usr/share/bpftrace/tools/runqlen.bt
/usr/share/bpftrace/tools/setuids.bt
/usr/share/bpftrace/tools/statsnoop.bt
/usr/share/bpftrace/tools/swapin.bt
/usr/share/bpftrace/tools/syncsnoop.bt
/usr/share/bpftrace/tools/syscount.bt
/usr/share/bpftrace/tools/tcpaccept.bt
/usr/share/bpftrace/tools/tcpconnect.bt
/usr/share/bpftrace/tools/tcpdrop.bt
/usr/share/bpftrace/tools/tcplife.bt
/usr/share/bpftrace/tools/tcpretrans.bt
/usr/share/bpftrace/tools/tcpsynbl.bt
/usr/share/bpftrace/tools/threadsnoop.bt
/usr/share/bpftrace/tools/vfscount.bt
/usr/share/bpftrace/tools/vfsstat.bt
/usr/share/bpftrace/tools/writeback.bt
/usr/share/bpftrace/tools/xfsdist.bt
/usr/share/doc/bpftrace
/usr/share/doc/bpftrace/CONTRIBUTING-TOOLS.md
/usr/share/doc/bpftrace/README.md
/usr/share/doc/bpftrace/reference_guide.md
/usr/share/doc/bpftrace/tutorial_one_liners.md
/usr/share/licenses/bpftrace
/usr/share/licenses/bpftrace/LICENSE
/usr/share/man/man8/bashreadline.8.gz
/usr/share/man/man8/biolatency.8.gz
/usr/share/man/man8/biosnoop.8.gz
/usr/share/man/man8/biostacks.8.gz
/usr/share/man/man8/bitesize.8.gz
/usr/share/man/man8/bpftrace.8.gz
/usr/share/man/man8/capable.8.gz
/usr/share/man/man8/cpuwalk.8.gz
/usr/share/man/man8/dcsnoop.8.gz
/usr/share/man/man8/execsnoop.8.gz
/usr/share/man/man8/gethostlatency.8.gz
/usr/share/man/man8/killsnoop.8.gz
/usr/share/man/man8/loads.8.gz
/usr/share/man/man8/mdflush.8.gz
/usr/share/man/man8/naptime.8.gz
/usr/share/man/man8/oomkill.8.gz
/usr/share/man/man8/opensnoop.8.gz
/usr/share/man/man8/pidpersec.8.gz
/usr/share/man/man8/runqlat.8.gz
/usr/share/man/man8/runqlen.8.gz
/usr/share/man/man8/setuids.8.gz
/usr/share/man/man8/statsnoop.8.gz
/usr/share/man/man8/swapin.8.gz
/usr/share/man/man8/syncsnoop.8.gz
/usr/share/man/man8/syscount.8.gz
/usr/share/man/man8/tcpaccept.8.gz
/usr/share/man/man8/tcpconnect.8.gz
/usr/share/man/man8/tcpdrop.8.gz
/usr/share/man/man8/tcplife.8.gz
/usr/share/man/man8/tcpretrans.8.gz
/usr/share/man/man8/tcpsynbl.8.gz
/usr/share/man/man8/threadsnoop.8.gz
/usr/share/man/man8/vfscount.8.gz
/usr/share/man/man8/vfsstat.8.gz
/usr/share/man/man8/writeback.8.gz
/usr/share/man/man8/xfsdist.8.gz

References

Summary

In this tutorial we learn how to install bpftrace on CentOS 8 using yum and dnf.