babeltrace2-run - Linux


Overview

babeltrace2-run is a command-line tool that allows you to record and inspect kernel events in the eBPF format. It’s designed to be a more modern and user-friendly alternative to the traditional perf command.

Syntax

babeltrace2-run [options] [-- <command>]

Options/Flags

  • -d, –duration: Set the duration of the recording in seconds.
  • -e, –event: Specify the event to record. Can be a wildcard pattern.
  • -f, –format: Specify the output format. Available formats: text, json, e2e, proto.
  • -i, –interval: Specify the interval between recordings in seconds.
  • -k, –kernel-trace: Enable tracing of kernel events.
  • -o, –output: Specify the output file. If not specified, output is printed to stdout.
  • -p, –pid: Specify the PID of the process to record.
  • -q, –quiet: Suppress all output except for errors.
  • –help: Display help information.

Examples

Simple example:

Record kernel events for 10 seconds and output the results in text format:

babeltrace2-run -d 10 -f text

Advanced example:

Record events for the process with PID 1234, filter for events matching the wildcard pattern "sched*," and output the results in JSON format:

babeltrace2-run -p 1234 -e sched* -f json

Common Issues

  • Permission denied: Ensure you have sufficient permissions to record events (usually requires root).
  • No events recorded: Check that the event you specified is enabled in the kernel.
  • Output file not created: Check that the output directory exists and has write permissions.

Integration

babeltrace2-run can be combined with other Linux tools for advanced analysis. For example, you can pipe the output of babeltrace2-run to tools like jq or grep for further filtering and analysis.

Related Commands

  • perf
  • eBPF
  • bpftrace