Merge pull request #182 from brendangregg/master
simplify code using new features
diff --git a/examples/disksnoop.py b/examples/disksnoop.py
index c73bab9..6da269b 100755
--- a/examples/disksnoop.py
+++ b/examples/disksnoop.py
@@ -12,7 +12,6 @@
from __future__ import print_function
from bcc import BPF
-import sys
REQ_WRITE = 1 # from include/linux/blk_types.h
@@ -24,13 +23,6 @@
# header
print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)"))
-# open trace pipe
-try:
- trace = open("/sys/kernel/debug/tracing/trace_pipe", "r")
-except:
- print("ERROR: opening trace_pipe", file=sys.stderr)
- exit(1)
-
# format output
while 1:
(task, pid, cpu, flags, ts, msg) = b.trace_readline_fields()
diff --git a/tools/syncsnoop b/tools/syncsnoop
index 4df1931..4fce39a 100755
--- a/tools/syncsnoop
+++ b/tools/syncsnoop
@@ -13,7 +13,6 @@
from __future__ import print_function
from bcc import BPF
-import sys
# load BPF program
b = BPF(text = """
@@ -22,26 +21,12 @@
return 0;
};
""")
-b.attach_kprobe(event="sys_sync")
+b.attach_kprobe(event="sys_sync", fn_name="do_sync")
# header
print("%-18s %s" % ("TIME(s)", "CALL"))
-# open trace pipe
-try:
- trace = open("/sys/kernel/debug/tracing/trace_pipe", "r")
-except:
- print("ERROR: opening trace_pipe", file=sys.stderr)
- exit(1)
-
# format output
while 1:
- try:
- line = trace.readline().rstrip()
- except KeyboardInterrupt:
- pass; exit()
-
- prolog, time_s, colon, word = line.rsplit(" ", 3)
- time_s = time_s[:-1] # strip trailing ":"
-
- print("%-18s %s" % (time_s, word))
+ (task, pid, cpu, flags, ts, msg) = b.trace_readline_fields()
+ print("%-18.9f %s" % (ts, msg))
diff --git a/tools/vfscount b/tools/vfscount
index 9d06d7e..d669862 100755
--- a/tools/vfscount
+++ b/tools/vfscount
@@ -12,9 +12,7 @@
from __future__ import print_function
from bcc import BPF
-from ctypes import c_ushort, c_int, c_ulonglong
-from time import sleep, strftime
-from sys import stderr
+from time import sleep
# load BPF program
b = BPF(src_file = "vfscount.c")