Skip to content

Instantly share code, notes, and snippets.

@cmittendorf
Created February 26, 2015 18:11
Show Gist options
  • Save cmittendorf/4d8d40c214a8b45b411c to your computer and use it in GitHub Desktop.
Save cmittendorf/4d8d40c214a8b45b411c to your computer and use it in GitHub Desktop.
A dtrace script for tracing all SQL queries a mysql server is executing. Call this script using `sudo ./trace_all_queries.d -p `pgrep mysqld`.
#!/usr/sbin/dtrace -s
#pragma D option quiet
pid$target:mysqld:*mysql_parse*:entry
{
printf("[%Y] %s\n", walltimestamp, copyinstr(arg1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment