#
# 11-Aug-2015 Brendan Gregg Created this.
+from __future__ import print_function
from bpf import BPF
import sys
BPF.attach_kprobe(b.load_func("do_completion", BPF.KPROBE), "blk_update_request")
# header
-print "%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)")
+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 >> sys.stderr, "ERROR: opening trace_pipe"
+ print("ERROR: opening trace_pipe", file=sys.stderr)
exit(1)
# format output
type_s = "R"
ms = float(int(us_s, 10)) / 1000
- print "%-18s %-2s %-7s %8.2f" % (time_s, type_s, bytes_s, ms)
+ print("%-18s %-2s %-7s %8.2f" % (time_s, type_s, bytes_s, ms))
S_COUNT = 1
# header
-print "Tracing... Ctrl-C to end."
+print("Tracing... Ctrl-C to end.")
# output
last = 0
except KeyboardInterrupt:
pass; exit()
- print "%s: PIDs/sec: %d" % (strftime("%H:%M:%S"),
- (stats[c_int(S_COUNT)].value - last))
+ print("%s: PIDs/sec: %d" % (strftime("%H:%M:%S"),
+ (stats[c_int(S_COUNT)].value - last)))
last = stats[c_int(S_COUNT)].value
#
# 13-Aug-2015 Brendan Gregg Created this.
+from __future__ import print_function
from bpf import BPF
import sys
BPF.attach_kprobe(b.load_func("do_sync", BPF.KPROBE), "sys_sync")
# header
-print "%-18s %s" % ("TIME(s)", "CALL")
+print("%-18s %s" % ("TIME(s)", "CALL"))
# open trace pipe
try:
trace = open("/sys/kernel/debug/tracing/trace_pipe", "r")
except:
- print >> sys.stderr, "ERROR: opening trace_pipe"
+ print("ERROR: opening trace_pipe", file=sys.stderr)
exit(1)
# format output
prolog, time_s, colon, word = line.rsplit(" ", 3)
time_s = time_s[:-1] # strip trailing ":"
- print "%-18s %s" % (time_s, word)
+ print("%-18s %s" % (time_s, word))
#
# 14-Aug-2015 Brendan Gregg Created this.
+from __future__ import print_function
from bpf import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
try:
syms = open(symfile, "r")
except:
- print >> stderr, "ERROR: reading " + symfile
+ print("ERROR: reading " + symfile, file=sys.stderr)
exit()
line = syms.readline()
for line in iter(syms):
start = -1
end = len(ksym_addrs)
while end != start + 1:
- mid = (start + end) / 2
+ mid = int((start + end) / 2)
if addr < ksym_addrs[mid]:
end = mid
else:
counts = b.get_table("counts")
# header
-print "Tracing... Ctrl-C to end."
+print("Tracing... Ctrl-C to end.")
# output
try:
except KeyboardInterrupt:
pass
-print "\n%-16s %-12s %8s" % ("ADDR", "FUNC", "COUNT")
+print("\n%-16s %-12s %8s" % ("ADDR", "FUNC", "COUNT"))
for k, v in sorted(counts.items(), key=lambda counts: counts[1].value):
- print "%-16x %-12s %8d" % (k.ip, ksym(k.ip), v.value)
+ print("%-16x %-12s %8d" % (k.ip, ksym(k.ip), v.value))