Home | History | Annotate | Download | only in old
      1 #!/usr/bin/python
      2 # @lint-avoid-python-3-compatibility-imports
      3 #
      4 # syncsnoop Trace sync() syscall.
      5 #           For Linux, uses BCC, eBPF. Embedded C.
      6 #
      7 # Written as a basic example of BCC trace & reformat. See
      8 # examples/hello_world.py for a BCC trace with default output example.
      9 #
     10 # Copyright (c) 2015 Brendan Gregg.
     11 # Licensed under the Apache License, Version 2.0 (the "License")
     12 #
     13 # 13-Aug-2015   Brendan Gregg   Created this.
     14 
     15 from __future__ import print_function
     16 from bcc import BPF
     17 
     18 # load BPF program
     19 b = BPF(text="""
     20 void kprobe__sys_sync(void *ctx) {
     21     bpf_trace_printk("sync()\\n");
     22 };
     23 """)
     24 
     25 # header
     26 print("%-18s %s" % ("TIME(s)", "CALL"))
     27 
     28 # format output
     29 while 1:
     30     (task, pid, cpu, flags, ts, msg) = b.trace_fields()
     31     print("%-18.9f %s" % (ts, msg))
     32