3
# Copyright (c) 2009 Sun Microsystems, Inc.
4
# Use is subject to license terms.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 2 of the License.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
# Show the time taken to execute a query, include the bytes and time taken
20
# to transfer the information over the network to/from the client
22
#pragma D option quiet
23
#pragma D option dynvarsize=4m
27
printf("%-2s %-30s %-10s %9s %18s %-s \n",
28
"St", "Who", "DB", "ConnID", "Dur microsec", "Query");
33
self->query = copyinstr(arg0);
34
self->who = strjoin(copyinstr(arg3),strjoin("@",copyinstr(arg4)));
35
self->db = copyinstr(arg2);
37
self->querystart = timestamp;
39
self->netwritecum = 0;
40
self->netwritebase = 0;
43
self->netreadbase = 0;
46
mysql*:::net-write-start
48
self->netwrite += arg0;
49
self->netwritebase = timestamp;
52
mysql*:::net-write-done
54
self->netwritecum += (timestamp - self->netwritebase);
55
self->netwritebase = 0;
58
mysql*:::net-read-start
60
self->netreadbase = timestamp;
63
mysql*:::net-read-done
65
self->netread += arg1;
66
self->netreadcum += (timestamp - self->netreadbase);
67
self->netreadbase = 0;
72
this->elapsed = (timestamp - self->querystart) /1000000;
73
printf("%2d %-30s %-10s %9d %18d %s\n",
74
arg0, self->who, self->db,
75
self->connid, this->elapsed, self->query);
76
printf("Net read: %d bytes (%d ms) write: %d bytes (%d ms)\n",
77
self->netread, (self->netreadcum/1000000),
78
self->netwrite, (self->netwritecum/1000000));