The connection-start
and
connection-done
probes enclose a connection
from a client, regardless of whether the connection is through a
socket or network connection.
connection-start(connectionid, user, host) connection-done(status, connectionid)
connection-start
— is triggered
after a connection and successful login/authentication have
been completed by a client. The arguments contain the
connection information:
connectionid
— is an
unsigned long
containing the
connection ID. This is the same as the process ID shown
as the Id
value in the output from
SHOW PROCESSLIST
.
user
— is the username used
when authenticating. The value will be blank for the
anonymous user.
host
— is the host of the
client connection. For a connection made using UNIX
sockets, the value will be blank.
connection-done
— is triggered just
as the connection to the client has been closed. The
arguments are:
status
— the status of the
connection when it was closed. A logout operation will
have a value of 0; any other termination of the
connection has a nonzero value.
connectionid
— the connection
ID of the connection that was closed.
The following D script will quantify and summarize the average duration of individual connections, and provide a count, dumping the information every 60 seconds:
#!/usr/sbin/dtrace -s mysql*:::connection-start { self->start = timestamp; } mysql*:::connection-done /self->start/ { @ = quantize(((timestamp - self->start)/1000000)); self->start = 0; } tick-60s { printa(@); }
When executed on a server with a large number of clients you might see output similar to this:
1 57413 :tick-60s value ------------- Distribution ------------- count -1 | 0 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 30011 1 | 59 2 | 5 4 | 20 8 | 29 16 | 18 32 | 27 64 | 30 128 | 11 256 | 10 512 | 1 1024 | 6 2048 | 8 4096 | 9 8192 | 8 16384 | 2 32768 | 1 65536 | 1 131072 | 0 262144 | 1 524288 | 0
User Comments
Add your own comment.