Files
ldb/ebpf/leak_detect/tcp_probe.bpf

39 lines
776 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bpftrace
BEGIN
{
printf("开始统计 kvstore 进程的 tcp_rcv_established 调用次数...\n");
printf("每 5 秒打印一次统计Ctrl-C 退出\n\n");
// 统计变量
@enter = 0;
@exit = 0;
}
interval:s:5
{
time("%H:%M:%S");
printf(" tcp_rcv_established 调用次数: %10d\n", @enter);
printf(" tcp_rcv_established ret 调用次数: %10d\n", @exit);
// 可选:如果想每轮清零统计,取消下面注释
// clear(@enter);
// clear(@exit);
}
kprobe:tcp_rcv_established
{
@enter++;
}
kretprobe:tcp_rcv_established
{
@exit++;
}
END
{
printf("\n最终统计\n");
printf("tcp_rcv_established : %d 次\n", @enter);
printf("tcp_rcv_established ret: %d 次\n", @exit);
}