Advertisement
Guest User

Untitled

a guest
May 25th, 2019
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #!/usr/bin/env bpftrace
  2. /*
  3. * killsnoop Trace signals issued by the kill() syscall.
  4. * For Linux, uses bpftrace and eBPF.
  5. *
  6. * USAGE: killsnoop.bt
  7. *
  8. * Also a basic example of bpftrace.
  9. *
  10. * This is a bpftrace version of the bcc tool of the same name.
  11. *
  12. * Copyright 2018 Netflix, Inc.
  13. * Licensed under the Apache License, Version 2.0 (the "License")
  14. *
  15. * 07-Sep-2018 Brendan Gregg Created this.
  16. */
  17.  
  18. BEGIN
  19. {
  20. printf("Tracing kill() signals... Hit Ctrl-C to end.\n");
  21. printf("%-9s %-6s %-16s %-4s %-6s %s\n", "TIME", "PID", "COMM", "SIG",
  22. "TPID", "RESULT");
  23. }
  24.  
  25. tracepoint:syscalls:sys_enter_kill
  26. {
  27. @tpid[tid] = args->pid;
  28. @tsig[tid] = args->sig;
  29. }
  30.  
  31. tracepoint:syscalls:sys_exit_kill
  32. /@tpid[tid]/
  33. {
  34. if (@tsig[tid] != 0) {
  35. time("%H:%M:%S ");
  36. printf("%-6d %-16s %-4d %-6d %d\n", pid, comm, @tsig[tid], @tpid[tid],
  37. args->ret);
  38. delete(@tpid[tid]);
  39. delete(@tsig[tid]);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement