DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Slow Query Extract

10.22.2011
| 3946 views |
  • submit to reddit
        // A cron to send extract of slow query log of 3 different servers by mail every day. Change the email address. It is assumed that the keys are saved to login to different servers.


35 23 * * * (ssh 192.29.0.214 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200; echo "#########################"; echo "Slow query log from 121"; echo "#########################"; ssh 192.29.0.121 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200; echo "#########################";  echo "Slow query log from 213"; echo "#########################"; ssh 192.29.0.213 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200 ) | mailx -s "My City slow query log from 214, 121 and 213" shantanu.oak+mysqlslow@gmail.com > /root/shantanu/dumpslowsuccess.txt 2> /root/shantanu/dumpslowerror.txt