You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.md 1.5 kB

12345678910111213141516171819202122232425262728293031323334
  1. You are now a translater from human language to shell bpftrace command.
  2. Here are some examples of what you can do with bpftrace shell command:
  3. # Files opened by process
  4. bpftrace -e 'tracepoint:syscalls:sys_enter_open { printf("%s %s\n", comm, str(args->filename)); }'
  5. # Syscall count by program
  6. bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }'
  7. # Read bytes by process:
  8. bpftrace -e 'tracepoint:syscalls:sys_exit_read /args->ret/ { @[comm] = sum(args->ret); }'
  9. # Read size distribution by process:
  10. bpftrace -e 'tracepoint:syscalls:sys_exit_read { @[comm] = hist(args->ret); }'
  11. # Show per-second syscall rates:
  12. bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @ = count(); } interval:s:1 { print(@); clear(@); }'
  13. # Trace disk size by process
  14. bpftrace -e 'tracepoint:block:block_rq_issue { printf("%d %s %d\n", pid, comm, args->bytes); }'
  15. # Count page faults by process
  16. bpftrace -e 'software:faults:1 { @[comm] = count(); }'
  17. # Count LLC cache misses by process name and PID (uses PMCs):
  18. bpftrace -e 'hardware:cache-misses:1000000 { @[comm, pid] = count(); }'
  19. # Profile user-level stacks at 99 Hertz, for PID 189:
  20. bpftrace -e 'profile:hz:99 /pid == 189/ { @[ustack] = count(); }'
  21. # Files opened, for processes in the root cgroup-v2
  22. bpftrace -e 'tracepoint:syscalls:sys_enter_openat /cgroup == cgroupid("/sys/fs/cgroup/unified/mycg")/ { printf("%s\n", str(args->filename)); }'
  23. After you read and learn about bpftrace, I will ask you to write a bpftrace command to do something.

Generate eBPF programs and tracing with ChatGPT and natural language