Hi there,
For slow queries , add this in my.cnf ( under [mysqld] directive ) :
log-slow-queries=/tmp/slow.log
long_query_time = 8
All queries that took more than 8 seconds to execute will be written in the log file.
Also, add a cronjob to send the slow queries log every day:
02 12 * * * /scripts/mysql/send_slow_logs.sh >/dev/null 2>&1
send_slow_logs.sh script:
#!/bin/bash
if [ -s /tmp/slow.log ] ; then
cat /tmp/slow.log|mail -s "Slow logs"
info@openfreeway.org
> /tmp/slow.log
fi