From 31f158802e4d4271a53365ccf59f56d06045e05c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 15:06:50 +0530 Subject: [PATCH] Added slow log function --- src/vendor/ee_ven_install_utils.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index b211c71f..94e490b6 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -104,21 +104,23 @@ function ee_ven_install_utils() # Execute on MySQL log-rotation dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 if [ $? -eq 0 ]; then - sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server - echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server - echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server - echo -e " --history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server - echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server - echo -e "}" >> /etc/logrotate.d/mysql-server + echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--review D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh else - sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server - echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server - echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server - echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server - echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server - echo -e "}" >> /etc/logrotate.d/mysql-server + echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--review-history D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh fi # Download pt-query-advisor Fixed #189