A Slow Query log script for Tomcat Access logs

Run this at midnight and you will have all the slow queries in the slow_query.log file

  1. NOW=$(date +"%Y-%m-%d")
  2. LOGFILE="slow_query.$NOW.log"
  3. $(touch /var/log/tomcat6/$LOGFILE)
  4. ## 800 msec is a maximum value for solr. Let's filter everything above that
  5. $(cat /var/log/tomcat6/catalina.out | grep 'QTime' | awk -F 'QTime=' 'int($NF) >= 800' > /var/log/tomcat6/$LOGFILE)

This snippet will output your queries that have QTime's above 800msec. Do have you better snippets? Please post them in the comments