#!/usr/bin/bpftrace BEGIN { printf("Tracing nf_hook_slow... Ctrl+C to stop.\n\n"); } /* fentry fires at the entry of the kernel function. * Faster and lower-overhead than kprobe. * 'comm' is a bpftrace built-in: the name of the current process. */ fentry:nf_hook_slow { @invocations_by_process[comm]++; } /* Print and reset every 3 seconds */ interval:s:3 { printf("-- %s --\n", strftime("%H:%M:%S", nsecs)); print(@invocations_by_process); printf("\n"); clear(@invocations_by_process); } END { printf("Done.\n"); }