diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-03-06 13:31:03 +0100 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-03-06 13:31:03 +0100 |
commit | 5a5343d2e6c68740e10d2e03b11863e4c6a13a15 (patch) | |
tree | 38ce3e61e0bd8dff96dc8a0f9c706ee81c583af4 /support-files/dtrace/query-network-time.d | |
parent | bceddafd990b708bea02b5a2953fde20feff1f4e (diff) | |
download | mariadb-git-5a5343d2e6c68740e10d2e03b11863e4c6a13a15.tar.gz |
Added DTrace example scripts
Diffstat (limited to 'support-files/dtrace/query-network-time.d')
-rw-r--r-- | support-files/dtrace/query-network-time.d | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/support-files/dtrace/query-network-time.d b/support-files/dtrace/query-network-time.d new file mode 100644 index 00000000000..f0483778fb0 --- /dev/null +++ b/support-files/dtrace/query-network-time.d @@ -0,0 +1,63 @@ +#!/usr/sbin/dtrace -s +# +# Show the time taken to execute a query, include the bytes and time taken +# to transfer the information over the network to/from the client + +#pragma D option quiet +#pragma D option dynvarsize=4m + +dtrace:::BEGIN +{ + printf("%-2s %-30s %-10s %9s %18s %-s \n", + "St", "Who", "DB", "ConnID", "Dur microsec", "Query"); +} + +mysql*:::query-start +{ + self->query = copyinstr(arg0); + self->who = strjoin(copyinstr(arg3),strjoin("@",copyinstr(arg4))); + self->db = copyinstr(arg2); + self->connid = arg1; + self->querystart = timestamp; + self->netwrite = 0; + self->netwritecum = 0; + self->netwritebase = 0; + self->netread = 0; + self->netreadcum = 0; + self->netreadbase = 0; +} + +mysql*:::net-write-start +{ + self->netwrite += arg0; + self->netwritebase = timestamp; +} + +mysql*:::net-write-done +{ + self->netwritecum += (timestamp - self->netwritebase); + self->netwritebase = 0; +} + +mysql*:::net-read-start +{ + self->netreadbase = timestamp; +} + +mysql*:::net-read-done +{ + self->netread += arg1; + self->netreadcum += (timestamp - self->netreadbase); + self->netreadbase = 0; +} + +mysql*:::query-done +{ + this->elapsed = (timestamp - self->querystart) /1000000; + printf("%2d %-30s %-10s %9d %18d %s\n", + arg0, self->who, self->db, + self->connid, this->elapsed, self->query); + printf("Net read: %d bytes (%d ms) write: %d bytes (%d ms)\n", + self->netread, (self->netreadcum/1000000), + self->netwrite, (self->netwritecum/1000000)); +} |