Skip to content

Instantly share code, notes, and snippets.

@danmackinlay
Created August 27, 2009 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmackinlay/176189 to your computer and use it in GitHub Desktop.
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
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