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