diff options
Diffstat (limited to 'support-files/dtrace/query-network-time.d')
-rw-r--r-- | support-files/dtrace/query-network-time.d | 79 |
1 files changed, 79 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 00000000..bf3c05e5 --- /dev/null +++ b/support-files/dtrace/query-network-time.d @@ -0,0 +1,79 @@ +#!/usr/sbin/dtrace -s +# +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +# +# 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)); +} |