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