public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Stan Cox <scox@redhat.com>
To: systemtap <systemtap@sources.redhat.com>
Subject: mysql static probes demo
Date: Tue, 27 Jan 2009 01:21:00 -0000	[thread overview]
Message-ID: <1232742551.1739.64.camel@localhost.localdomain> (raw)
Message-ID: <20090127012100.jKP-URfpsqSP5VxoezZvlJTJFp4-wdHUTeFvp8AFV9c@z> (raw)

Here is a demo of mysql being probed.  An example probe from the mysql
file probes.d is:
probe query__exec__start(char *query,
                         unsigned long connid,
                         char *db_name,
                         char *user,
                         char *host,
                         int exec_type);
The dtrace python script massages this into a header file with entries
like:
#define MYSQL_QUERY_EXEC_START(arg1,arg2,arg3,arg4,arg5,arg6)  \
STAP_PROBE6(provider,query__exec__start,arg1,arg2,arg3,arg4,arg5,arg6)

Which will be invoked by the mysql sources as:
 MYSQL_QUERY_EXEC_START(thd->query,
                         thd->thread_id,
                         (char *) (thd->db ? thd->db : ""),
                         thd->security_ctx->priv_user,
                         (char *) thd->security_ctx->host_or_ip,
                         2);

For which stap has the probe definition:
 probe process("/usr/local/libexec/mysqld").mark("query__exec__start") {
  arg1=user_string($arg1)
  arg3=user_string($arg3)
  arg4=user_string($arg4)
  arg5=user_string($arg5)
  printf("%s %s %#x %s %s %s\n","query__exec__start",  arg1, $arg2,
         arg3, arg4, arg5); }

Which gives the trace output:
query__exec__start insert into employee values ('Fred
Flintstone','Quarry Worker','Rock Digger') 0xa bedrock root localhost

Here is trace output for granting db creation access, creating a db, inserting 
into the db, and retrieving from the db.

query__exec__start GRANT all privileges on *.* TO scox 0xa mysql root
localhost
handler__wrlock__start mysql user 
handler__wrlock__done 0x0
handler__wrlock__start mysql db 
handler__wrlock__done 0x0
insert__row__start mysql user 
insert__row__done 0x0
handler__unlock__start mysql user 
handler__unlock__done 0x0
handler__unlock__start mysql db 
handler__unlock__done 0x0
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss create database bedrock
query__parse__start create database bedrock
query__parse__done 0x0
query__exec__start create database bedrock 0xa mysql root localhost
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss show databases
query__parse__start show databases
query__parse__done 0x0
query__exec__start show databases 0xa mysql root localhost
select__start show databases
select__done 0x0 0x4 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss SELECT DATABASE()
query__parse__start SELECT DATABASE()
query__parse__done 0x0
query__exec__start SELECT DATABASE() 0xa mysql root localhost
select__start SELECT DATABASE()
select__done 0x0 0x1 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x2 root localhost
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss show tables
query__parse__start show tables
query__parse__done 0x0
query__exec__start show tables 0xa mysql root localhost
select__start show tables
select__done 0x0 0x19 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss SELECT DATABASE()
query__parse__start SELECT DATABASE()
query__parse__done 0x0
query__exec__start SELECT DATABASE() 0xa mysql root localhost
select__start SELECT DATABASE()
select__done 0x0 0x1 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x2 root localhost
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss show databases
query__parse__start show databases
query__parse__done 0x0
query__exec__start show databases 0xa bedrock root localhost
select__start show databases
select__done 0x0 0x4 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss show tables
query__parse__start show tables
query__parse__done 0x0
query__exec__start show tables 0xa bedrock root localhost
select__start show tables
select__done 0x0 0x0 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss create table employee (Name char(20), Dept char(20),
jobTitle char(20))
query__parse__start create table employee (Name char(20), Dept char(20),
jobTitle char(20))
query__parse__done 0x0
query__exec__start create table employee (Name char(20), Dept char(20),
jobTitle char(20)) 0xa bedrock root localhost
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss describe employee
query__parse__start describe employee
query__parse__done 0x0
query__exec__start describe employee 0xa bedrock root localhost
select__start describe employee
insert__row__start  /tmp/#sql_7b64_0 
insert__row__done 0x0
insert__row__start  /tmp/#sql_7b64_0 
insert__row__done 0x0
insert__row__start  /tmp/#sql_7b64_0 
insert__row__done 0x0
select__done 0x0 0x3 
query__exec__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__parse__done 0x1
net__write__start 0x9b
net__write__done 0x0
query__done 0x1
command__done 0x1
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss insert into employee values ('Fred
Flintstone','Quarry Worker','Rock Digger')
query__parse__start insert into employee values ('Fred
Flintstone','Quarry Worker','Rock Digger')
query__parse__done 0x0
query__exec__start insert into employee values ('Fred
Flintstone','Quarry Worker','Rock Digger') 0xa bedrock root localhost
insert__start insert into employee values ('Fred Flintstone','Quarry
Worker','Rock Digger')
handler__wrlock__start bedrock employee 
handler__wrlock__done 0x0
insert__row__start bedrock employee 
insert__row__done 0x0
query__exec__done 0x0
handler__unlock__start bedrock employee 
handler__unlock__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss insert into employee values ('Wilma
Flintstone','Finance','Analyst')
query__parse__start insert into employee values ('Wilma
Flintstone','Finance','Analyst')
query__parse__done 0x0
query__exec__start insert into employee values ('Wilma
Flintstone','Finance','Analyst') 0xa bedrock root localhost
insert__start insert into employee values ('Wilma
Flintstone','Finance','Analyst')
handler__wrlock__start bedrock employee 
handler__wrlock__done 0x0
insert__row__start bedrock employee 
insert__row__done 0x0
query__exec__done 0x0
handler__unlock__start bedrock employee 
handler__unlock__done 0x0
query__done 0x0
command__done 0x0
net__read__start 
command__start 0xa 0x3 root localhost
query__cache__miss select * from employee
query__parse__start select * from employee
query__parse__done 0x0
query__exec__start select * from employee 0xa bedrock root localhost
handler__rdlock__start bedrock employee 
handler__rdlock__done 0x0
select__start select * from employee
handler__unlock__start bedrock employee 



             reply	other threads:[~2009-01-26 17:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-23 22:19 Stan Cox [this message]
2009-01-26 20:03 ` Mark Wielaard
2009-01-27  1:21 ` Stan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1232742551.1739.64.camel@localhost.localdomain \
    --to=scox@redhat.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).