/
usr
/
share
/
doc
/
bpftrace
/
examples
/
/usr/share/doc/bpftrace/examples
mkdir
upload
Name
Size
Mode
Actions
bashreadline_example.txt
722
0644
edit
dl
rm
biolatency_example.txt
1790
0644
edit
dl
rm
biosnoop_example.txt
2056
0644
edit
dl
rm
biostacks_example.txt
1914
0644
edit
dl
rm
bitesize_example.txt
3003
0644
edit
dl
rm
capable_example.txt
2659
0644
edit
dl
rm
cpuwalk_example.txt
4919
0644
edit
dl
rm
dcsnoop_example.txt
4612
0644
edit
dl
rm
execsnoop_example.txt
1535
0644
edit
dl
rm
gethostlatency_example.txt
923
0644
edit
dl
rm
killsnoop_example.txt
846
0644
edit
dl
rm
loads_example.txt
864
0644
edit
dl
rm
mdflush_example.txt
1866
0644
edit
dl
rm
naptime_example.txt
844
0644
edit
dl
rm
oomkill_example.txt
1668
0644
edit
dl
rm
opensnoop_example.txt
2528
0644
edit
dl
rm
pidpersec_example.txt
1504
0644
edit
dl
rm
runqlat_example.txt
8632
0644
edit
dl
rm
runqlen_example.txt
980
0644
edit
dl
rm
setuids_example.txt
2441
0644
edit
dl
rm
ssllatency_example.txt
4510
0644
edit
dl
rm
sslsnoop_example.txt
1916
0644
edit
dl
rm
statsnoop_example.txt
2738
0644
edit
dl
rm
swapin_example.txt
549
0644
edit
dl
rm
syncsnoop_example.txt
541
0644
edit
dl
rm
syscount_example.txt
1144
0644
edit
dl
rm
tcpaccept_example.txt
1350
0644
edit
dl
rm
tcpconnect_example.txt
1085
0644
edit
dl
rm
tcpdrop_example.txt
1256
0644
edit
dl
rm
tcplife_example.txt
1597
0644
edit
dl
rm
tcpretrans_example.txt
1153
0644
edit
dl
rm
tcpsynbl_example.txt
940
0644
edit
dl
rm
threadsnoop_example.txt
1182
0644
edit
dl
rm
undump_example.txt
680
0644
edit
dl
rm
vfscount_example.txt
1199
0644
edit
dl
rm
vfsstat_example.txt
929
0644
edit
dl
rm
writeback_example.txt
1962
0644
edit
dl
rm
xfsdist_example.txt
3419
0644
edit
dl
rm
Edit:
/usr/share/doc/bpftrace/examples/oomkill_example.txt
(1668B)
Demonstrations of oomkill, the Linux bpftrace/eBPF version. oomkill is a simple program that traces the Linux out-of-memory (OOM) killer, and shows basic details on one line per OOM kill: # ./oomkill.bt Tracing oom_kill_process()... Ctrl-C to end. 21:03:39 Triggered by PID 3297 ("ntpd"), OOM kill of PID 22516 ("perl"), 3850642 pages, loadavg: 0.99 0.39 0.30 3/282 22724 21:03:48 Triggered by PID 22517 ("perl"), OOM kill of PID 22517 ("perl"), 3850642 pages, loadavg: 0.99 0.41 0.30 2/282 22932 The first line shows that PID 22516, with process name "perl", was OOM killed when it reached 3850642 pages (usually 4 Kbytes per page). This OOM kill happened to be triggered by PID 3297, process name "ntpd", doing some memory allocation. The system log (dmesg) shows pages of details and system context about an OOM kill. What it currently lacks, however, is context on how the system had been changing over time. I've seen OOM kills where I wanted to know if the system was at steady state at the time, or if there had been a recent increase in workload that triggered the OOM event. oomkill provides some context: at the end of the line is the load average information from /proc/loadavg. For both of the oomkills here, we can see that the system was getting busier at the time (a higher 1 minute "average" of 0.99, compared to the 15 minute "average" of 0.30). oomkill can also be the basis of other tools and customizations. For example, you can edit it to include other task_struct details from the target PID at the time of the OOM kill, or to run other commands from the shell. There is another version of this tool in bcc: https://github.com/iovisor/bcc
Save
cmd:
run