diff --git a/bin/easyengine b/bin/easyengine index a9f49c6f..676e4f39 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -736,8 +736,10 @@ elif [ "$EE_FIRST" = "secure" ]; then # Clean cache elif [ "$EE_FIRST" = "clean" ]; then - ee_mod_clean ${@:2} + ee_mod_clean ${@:2} +elif [ "$EE_FIRST" = "import-slow-log"];then + ee_lib_import_slow_log # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh index 3f6599f4..9575fb08 100644 --- a/src/lib/ee_lib_import_slow_log.sh +++ b/src/lib/ee_lib_import_slow_log.sh @@ -3,15 +3,20 @@ function ee_lib_import_slow_log() { - dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 - if [ $? -eq 0 ]; then - ee_anemometer_history=history + if [ -d /var/www/22222/htdocs/db/anemometer ]; then + ee_lib_echo "Importing MySQL slow log, please wait..." + dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 + if [ $? -eq 0 ]; then + ee_anemometer_history=history + else + ee_anemometer_history=review-history + fi + + pt-query-digest --user=anemometer --password=anemometer_password \ + --review D=slow_query_log,t=global_query_review \ + --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log else - ee_anemometer_history=review-history + ee_lib_echo_fail "Anememoter is not installed" fi - - pt-query-digest --user=anemometer --password=anemometer_password \ - --review D=slow_query_log,t=global_query_review \ - --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ - --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log }