The Complete Production SOP: How to Deploy and Run eBPF BCC Tools Kernel & System Performance Tracing in Autonomous AI Agents
Production SOP to install and run eBPF BCC kernel performance tracing in Codex, Claude Code, and Cursor. Trace disk latency, execsnoop, and socket drops.
Technical Overview & Architectural Context
Autonomous coding and DevOps agents frequently fail when diagnosing elusive Linux kernel bottlenecks, storage I/O stalls, or TCP packet drops. Without structured operational guardrails, LLMs default to blunt CLI tools like top, ps, or iostat, which sample averaged metrics over elapsed intervals. These legacy counters completely miss sub-millisecond tail latency spikes, transient bursty fork/exec storms, and socket drops in epoll worker pools. Consequently, agents hallucinate speculative root causes or suggest dangerous kernel sysctl modifications that disrupt production environments. The eBPF BCC Tools Kernel & System Performance Tracing skill enforces deterministic SOP boundaries for agent runtimes like Codex, Claude Code, Cursor, and Windsurf. By binding the agent to battle-tested BPF Compiler Collection (BCC) instruments—such as biolatency, execsnoop, tcptop, and tcpretrans—the agent inspects live kernel tracepoints and kprobes non-intrusively. This skill restricts speculative actions, guarantees kernel header parity, mandates structured log capture, and validates system constraints before executing any privileged diagnostic workflow.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the eBPF BCC troubleshooting skill into your agent runtime workspace or global configuration directory.
Autonomous runtimes discover capabilities through standardized SKILL.md manifests. By placing the manifest in your agent's discovery directory (~/.agents/skills/ebpf-bcc-kernel-troubleshooting or .cursor/skills/), the runtime indexes frontmatter triggers like 'run bcc execsnoop' and 'measure disk latency biolatency bcc'. This activates dynamic kernel diagnostics only when relevant performance anomalies are reported.
mkdir -p ~/.agents/skills/ebpf-bcc-kernel-troubleshooting && curl -fsSL https://askills.dev/api/skills/ebpf-bcc-kernel-troubleshooting/raw -o ~/.agents/skills/ebpf-bcc-kernel-troubleshooting/SKILL.md---
name: "ebpf-bcc-kernel-troubleshooting"
description: "Diagnose elusive Linux performance bottlenecks, disk latency spikes, and socket drops using BCC."
metadata:
author: "IO Visor Project"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run bcc execsnoop"
- "measure disk latency biolatency bcc"
- "trace tcp connections tcptop"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Keep the SKILL.md permissions restricted to workspace writes; eBPF inspection commands output text digests that the agent can read and process into structured reports without requiring broad raw shell write permissions.
Ensure that the agent sandbox has read access to /sys/kernel/debug/tracing and /lib/modules/$(uname -r)/build if executing inside containerized runtime environments like Codex Desktop sandbox.
Kernel Headers Parity & Toolchain Validation
Ensure the target system has matching kernel headers and installed bpfcc-tools packages.
eBPF BCC compiles C-based kernel instrumentation on-the-fly via LLVM/Clang during invocation. If linux-headers do not match the exact running kernel string (`uname -r`), Clang compilation will abort. The agent must verify headers and binary presence before invoking diagnostic triggers.
sudo apt-get update && sudo apt-get install -y bpfcc-tools linux-headers-$(uname -r)#!/usr/bin/env bash
set -euo pipefail
if ! command -v biolatency-bpfcc &>/dev/null && ! command -v /usr/sbin/biolatency-bpfcc &>/dev/null; then
echo "Error: bpfcc-tools not installed or not in PATH" >&2
exit 1
fi
KERNEL_HEADER_DIR="/lib/modules/$(uname -r)/build"
if [ ! -d "${KERNEL_HEADER_DIR}" ]; then
echo "Error: Kernel headers missing at ${KERNEL_HEADER_DIR}" >&2
exit 1
fi
echo "eBPF BCC environment verified for kernel $(uname -r)"Package names differ across distros: Ubuntu/Debian uses 'bpfcc-tools' with binary suffix '-bpfcc' (e.g., execsnoop-bpfcc), while RHEL/Fedora uses 'bcc-tools' placed under /usr/share/bcc/tools/.
Docker containers require volume mounts `-v /lib/modules:/lib/modules:ro -v /sys:/sys:ro --privileged` to compile and load eBPF probe programs.
Intent Matching & Diagnostic Trigger Invocation
Instruct the AI agent using exact triggers to initiate targeted kernel telemetry collection.
Provide high-intent requests to Codex, Claude Code, Cursor, or Windsurf. The frontmatter triggers match intent strings directly, prompting the agent to assemble non-blocking inspection scripts or execute deterministic commands that collect sample distributions.
#!/usr/bin/env bash
# Execute 10-second bounded sample for block I/O latency distribution
sudo /usr/sbin/biolatency-bpfcc -m 10 1 > ./diagnostics/biolatency_report.txt
# Trace transient process creations with timestamps for 15 seconds
timeout 15s sudo /usr/sbin/execsnoop-bpfcc -T > ./diagnostics/execsnoop_trace.log || true
# Trace TCP retransmits indicating network congestion
timeout 15s sudo /usr/sbin/tcpretrans-bpfcc -l > ./diagnostics/tcpretrans_trace.log || trueAlways pair BCC tools with finite execution flags (such as passing interval and count to biolatency, or using timeout) to prevent background agent shell locks.
Never allow an agent to run unbounded BCC sniffers like `execsnoop` without a `timeout` boundary, as this exhausts agent context tokens when piping infinite stdout streams.
Histogram Parsing & Quality Gate Report Generation
Synthesize raw eBPF trace logs into structured actionable incident remediations.
The skill enforces that the agent does not merely dump raw terminal traces. Instead, it instructs the agent to read the collected logs, parse the latency buckets, identify top offending PIDs and TCP connection drops, and generate an actionable Markdown summary for DevOps engineers.
python3 -c "import json, re; print('Parsed kernel traces successfully')"import sys
import re
def parse_biolatency(filepath):
with open(filepath, 'r') as f:
content = f.read()
# Check for tail latency spikes in > 64ms or > 128ms buckets
outliers = re.findall(r'\s*(\d+)\s*->\s*(\d+)\s*:\s*(\d+)', content)
severe_spikes = [b for b in outliers if int(b[0]) >= 64 and int(b[2]) > 0]
if severe_spikes:
print(f"CRITICAL: Detected {len(severe_spikes)} latency buckets >= 64ms:")
for b in severe_spikes:
print(f" {b[0]}-{b[1]} ms: {b[2]} operations")
sys.exit(2)
print("OK: Disk I/O latency distribution within acceptable boundaries (<64ms).")
if __name__ == '__main__':
parse_biolatency(sys.argv[1] if len(sys.argv) > 1 else 'diagnostics/biolatency_report.txt')Direct the agent to commit the final diagnostics report to the repository's post-mortem folder, ensuring an audit trail for system regressions.
Avoid uncommitted temporary files in production branches by including `diagnostics/*.log` in the local `.gitignore`.
Real-World Scenario: Diagnosing Intermittent Database Micro-Stalls and Elevated Disk Tail Latency
“We are observing intermittent 200ms latency spikes on our PostgreSQL storage volume during peak traffic. Run bcc execsnoop and measure disk latency biolatency bcc to pinpoint whether background cron processes or NVMe queue stalls are causing the issue.”
Runtime Troubleshooting & Failure Modes
Root Cause: eBPF BCC JIT compilation fails because architecture-specific C header symlinks are missing or the multiarch header path is not linked in /usr/include.
sudo apt-get install -y gcc-multilib && sudo ln -sf /usr/include/$(uname -m)-linux-gnu/asm /usr/include/asmRoot Cause: The running kernel was compiled without dynamic kernel tracing probes, or the debugfs/tracefs virtual filesystem is not mounted at /sys/kernel/debug/tracing.
sudo mount -t tracefs nodev /sys/kernel/tracing || sudo mount -t debugfs nodev /sys/kernel/debugFrequently Asked Questions (eBPF BCC Tools Kernel & System Performance Tracing SOP)
Q:Can I use eBPF BCC Tools Kernel & System Performance Tracing across Codex, Claude Code, and Cursor simultaneously?
Yes. The SKILL.md specification is platform-agnostic and universally interpreted by Codex, Claude Code, Cursor, and Windsurf. Each runtime reads the trigger phrases and applies the procedural verification checks during prompt execution.
Q:How does eBPF BCC Tools Kernel & System Performance Tracing prevent context window overflow during long agent sessions?
The skill enforces discrete sampling intervals (e.g., `biolatency -m 10 1` or bounded `timeout` wrappers) and directs the agent to pipe raw telemetry to disk. The agent parses summarized histograms and anomalies rather than dumping multi-megabyte raw logs directly into the conversational context.
Q:Does this skill require escalated root or container permissions?
eBPF kernel probe attachments require administrative capabilities (specifically `CAP_BPF` or `CAP_SYS_ADMIN` under modern Linux kernels). The skill itself enforces least-privilege principles by restricting the agent's filesystem permissions to workspace boundaries while leveraging system-installed BCC binaries.
Ready to equip your autonomous agent with eBPF BCC Tools Kernel & System Performance Tracing?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.