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
: Triggered after a connection and successful login/authentication have been completed by a client. The arguments contain the connection information:connectionid
: Anunsigned long
containing the connection ID. This is the same as the process ID shown as theId
value in the output fromSHOW PROCESSLIST
.user
: The username used when authenticating. The value will be blank for the anonymous user.host
: The host of the client connection. For a connection made using UNIX sockets, the value will be blank.
connection-done
: 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