Connection Probes
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: