50 lines
2.0 KiB
Diff
50 lines
2.0 KiB
Diff
|
From fc72365ad7a3fb66902b3e2d0b0fb712eb8735d3 Mon Sep 17 00:00:00 2001
|
||
|
From: Jerome Marchand <jmarchan@redhat.com>
|
||
|
Date: Wed, 10 Jun 2020 18:29:11 +0200
|
||
|
Subject: [PATCH 4/4] tools: fix a python 3 map issue in dbstat and dbslower
|
||
|
|
||
|
In python 3, map returns an iterator and not a list anymore. This
|
||
|
patch cast the map into a list. It fixes the following error:
|
||
|
|
||
|
$ /usr/share/bcc/tools/dbstat mysql
|
||
|
Traceback (most recent call last):
|
||
|
File "/usr/share/bcc/tools/dbstat", line 95, in <module>
|
||
|
bpf = BPF(text=program, usdt_contexts=usdts)
|
||
|
File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 339, in __init__
|
||
|
ctx_array = (ct.c_void_p * len(usdt_contexts))()
|
||
|
TypeError: object of type 'map' has no len()
|
||
|
---
|
||
|
tools/dbslower.py | 2 +-
|
||
|
tools/dbstat.py | 2 +-
|
||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/tools/dbslower.py b/tools/dbslower.py
|
||
|
index 2f1b6a8b..e2ee7ad0 100755
|
||
|
--- a/tools/dbslower.py
|
||
|
+++ b/tools/dbslower.py
|
||
|
@@ -188,7 +188,7 @@ int query_end(struct pt_regs *ctx) {
|
||
|
args.pids = map(int, subprocess.check_output(
|
||
|
"pidof postgres".split()).split())
|
||
|
|
||
|
- usdts = map(lambda pid: USDT(pid=pid), args.pids)
|
||
|
+ usdts = list(map(lambda pid: USDT(pid=pid), args.pids))
|
||
|
for usdt in usdts:
|
||
|
usdt.enable_probe("query__start", "query_start")
|
||
|
usdt.enable_probe("query__done", "query_end")
|
||
|
diff --git a/tools/dbstat.py b/tools/dbstat.py
|
||
|
index a89b0971..a7d301b1 100755
|
||
|
--- a/tools/dbstat.py
|
||
|
+++ b/tools/dbstat.py
|
||
|
@@ -83,7 +83,7 @@ program = program.replace("SCALE", str(1000 if args.microseconds else 1000000))
|
||
|
program = program.replace("FILTER", "" if args.threshold == 0 else
|
||
|
"if (delta / 1000000 < %d) { return 0; }" % args.threshold)
|
||
|
|
||
|
-usdts = map(lambda pid: USDT(pid=pid), args.pids)
|
||
|
+usdts = list(map(lambda pid: USDT(pid=pid), args.pids))
|
||
|
for usdt in usdts:
|
||
|
usdt.enable_probe("query__start", "probe_start")
|
||
|
usdt.enable_probe("query__done", "probe_end")
|
||
|
--
|
||
|
2.25.4
|
||
|
|