Outil de recherche des 10 requêtes MySQL les plus fréquentes.
authorProgfou <jean-christophe.andre@auf.org>
Mon, 5 Mar 2012 19:43:11 +0000 (02:43 +0700)
committerProgfou <jean-christophe.andre@auf.org>
Mon, 5 Mar 2012 19:43:11 +0000 (02:43 +0700)
sysadmin/mysqlbinlog-top10 [new file with mode: 0755]

diff --git a/sysadmin/mysqlbinlog-top10 b/sysadmin/mysqlbinlog-top10
new file mode 100755 (executable)
index 0000000..2a523aa
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+for f in mysql-bin.[0-9]*
+do
+  mysqlbinlog $f | awk '
+/^use / {
+  db=substr($2,1,index($2,"/")-1)
+}
+/^(INSERT|DELETE)/ {
+  if ($2=="IGNORE") { table=$4 } else { table=$3 }
+  if (index(table,".")<=0) table=db"."table
+  printf("%s %s\n",$1,table)
+}
+/^(UPDATE|REPLACE)/ {
+  table=$2
+  if (index(table,".")<=0) table=db"."table
+  printf("%s %s\n",$1,table)
+}
+'
+done | sort | uniq -c | sort -n | tail -10