Created
August 27, 2009 09:17
-
-
Save danmackinlay/176189 to your computer and use it in GitHub Desktop.
quick little script for mysql_proxy's lua interpreter to show you when queies start and end so you can see if some are timing out. helps if you don't have control of the server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local log_file = 'mysql.log' | |
local fh = io.open(log_file, "a+") | |
function read_query( packet ) | |
if string.byte(packet) == proxy.COM_QUERY then | |
local query = string.sub(packet, 2) | |
local q = query | |
local cutoff = 160 | |
if cutoff < #query then | |
q = query:sub(1, cutoff) .. "..." | |
end | |
fh:write( string.format("%s %6d -- %s \n", | |
os.date('%Y-%m-%d %H:%M:%S'), | |
proxy.connection.server.thread_id, | |
q)) | |
fh:flush() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment