Skip to content

Commit bffd94f

Browse files
dbslower: fix a python3 bytes/string issue int the -x option
In python3, the find method requires a bytes-like object. It fixes the following error: $ dbslower mysql -x $(which mysqld) Traceback (most recent call last): File "/usr/share/bcc/tools/dbslower", line 72, in <module> if mysql_func_name.find("COM_DATA") >= 0: TypeError: a bytes-like object is required, not 'str' Also the -x option is currently undocumented in the man page and the example file. So let's ix that too.
1 parent e42a87f commit bffd94f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

man/man8/dbslower.8

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SH NAME
33
dbslower \- Trace MySQL/PostgreSQL server queries slower than a threshold.
44
.SH SYNOPSIS
5-
.B dbslower [-v] [-p PID [PID ...]] [-m THRESHOLD] {mysql,postgres}
5+
.B dbslower [-v] [-p PID [PID ...]] [-x PATH] [-m THRESHOLD] {mysql,postgres}
66
.SH DESCRIPTION
77
This traces queries served by a MySQL or PostgreSQL server, and prints
88
those that exceed a latency (query time) threshold. By default a threshold of
@@ -11,6 +11,8 @@ those that exceed a latency (query time) threshold. By default a threshold of
1111
This uses User Statically-Defined Tracing (USDT) probes, a feature added to
1212
MySQL and PostgreSQL for DTrace support, but which may not be enabled on a
1313
given installation. See requirements.
14+
Alternativly, MySQL queries can be traced without the USDT support using the
15+
-x option.
1416

1517
Since this uses BPF, only the root user can use this tool.
1618
.SH REQUIREMENTS
@@ -25,6 +27,10 @@ Print usage message.
2527
Trace this PID. If no PID is specified, the tool will attempt to automatically
2628
detect the MySQL or PostgreSQL processes running on the system.
2729
.TP
30+
\-x PATH
31+
Path to MySQL binary. This option allow to MySQL queries even when USDT probes
32+
aren't enabled on the MySQL server.
33+
.TP
2834
\-m THRESHOLD
2935
Minimum query latency (duration) to trace, in milliseconds. Default is 1 ms.
3036
.TP

tools/dbslower.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
(mysql_func_name, addr) = symbols[0]
7171

72-
if mysql_func_name.find("COM_DATA") >= 0:
72+
if mysql_func_name.find(b'COM_DATA') >= 0:
7373
mode = "MYSQL57"
7474
else:
7575
mode = "MYSQL56"

tools/dbslower_example.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ before the actual queries start coming in.
6767

6868
USAGE:
6969
# dbslower -h
70-
usage: dbslower.py [-h] [-v] [-p [PIDS [PIDS ...]]] [-m THRESHOLD]
70+
usage: dbslower.py [-h] [-v] [-p [PIDS [PIDS ...]]] [-x PATH] [-m THRESHOLD]
7171
{mysql,postgres}
7272

7373
positional arguments:
@@ -78,6 +78,7 @@ optional arguments:
7878
-v, --verbose print the BPF program
7979
-p [PID [PID ...]], --pid [PID [PID ...]]
8080
the pid(s) to trace
81+
-x PATH, --exe PATH path to binary
8182
-m THRESHOLD, --threshold THRESHOLD
8283
trace queries slower than this threshold (ms)
8384

@@ -86,3 +87,4 @@ examples:
8687
dbslower postgres -p 188 322 # trace specific PostgreSQL processes
8788
dbslower mysql -p 480 -m 30 # trace MySQL queries slower than 30ms
8889
dbslower mysql -p 480 -v # trace MySQL queries and print the BPF program
90+
dbslower mysql -x $(which mysqld) # trace MySQL queries with uprobes

0 commit comments

Comments
 (0)