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