Mitesh Shah
11 years ago
3 changed files with 45 additions and 48 deletions
@ -0,0 +1,45 @@ |
|||||
|
# MySQL debug |
||||
|
|
||||
|
function ee_mod_debug_mysql() |
||||
|
{ |
||||
|
if [ "$1" = "start" ]; then |
||||
|
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
||||
|
if [ $? -ne 0 ]; then |
||||
|
ee_lib_echo "Setup MySQL slow log, please wait..." |
||||
|
|
||||
|
mysql -e "set global slow_query_log = 'ON';" \ |
||||
|
|| ee_lib_error "Unable to setup slow_query_log, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" \ |
||||
|
|| ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global long_query_time = 2;" \ |
||||
|
|| ee_lib_error "Unable to setup long_query_time, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global log_queries_not_using_indexes = 'ON';" \ |
||||
|
|| ee_lib_error "Unable to setup log_queries_not_using_indexes, exit status = " $? |
||||
|
else |
||||
|
# Display message |
||||
|
ee_lib_echo "MySQL slow log already enabled" |
||||
|
fi |
||||
|
elif [ "$1" = "stop" ]; then |
||||
|
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
||||
|
if [ $? -eq 0 ]; then |
||||
|
ee_lib_echo "Disable MySQL slow log, please wait..." |
||||
|
|
||||
|
mysql -e "set global slow_query_log = 'OFF';" \ |
||||
|
|| ee_lib_error "Unable to setup slow_query_log, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" \ |
||||
|
|| ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global long_query_time = 10;" \ |
||||
|
|| ee_lib_error "Unable to setup long_query_time, exit status = " $? |
||||
|
|
||||
|
mysql -e "set global log_queries_not_using_indexes = 'OFF';" \ |
||||
|
else |
||||
|
# Display message |
||||
|
ee_lib_echo "MySQL slow log already disable" |
||||
|
fi |
||||
|
fi |
||||
|
} |
@ -1,24 +0,0 @@ |
|||||
# Enables MySQL debug mode |
|
||||
|
|
||||
function ee_mod_debug_mysql_start() |
|
||||
{ |
|
||||
# Check MySql slow logs is on |
|
||||
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG |
|
||||
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
|
||||
|
|
||||
if [ $? -ne 0 ]; then |
|
||||
# Enable MySQL slow logs |
|
||||
ee_lib_echo "Setting up MySQL slow log, please wait..." |
|
||||
mysql -u -e "set global slow_query_log = 'ON';" |
|
||||
mysql -u -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" |
|
||||
mysql -u -e "set global long_query_time=2;" |
|
||||
mysql -u -e "set global log_queries_not_using_indexes = 'ON';" |
|
||||
#sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf |
|
||||
#sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf |
|
||||
#sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf |
|
||||
else |
|
||||
# Lets disable MySQL restart trigger |
|
||||
#EE_DEBUG_MYSQL="" |
|
||||
ee_lib_echo "MySQL slow log already enabled" |
|
||||
fi |
|
||||
} |
|
@ -1,24 +0,0 @@ |
|||||
# MySQL debug mode |
|
||||
|
|
||||
function ee_mod_debug_mysql_stop() |
|
||||
{ |
|
||||
# Check MySql slow logs is off |
|
||||
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG |
|
||||
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
|
||||
|
|
||||
if [ $? -eq 0 ]; then |
|
||||
# Disable MySQL slow logs |
|
||||
ee_lib_echo "Stopping MySQL slow log, please wait..." |
|
||||
mysql -e "set global slow_query_log = 'OFF';" |
|
||||
mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" |
|
||||
mysql -e "set global long_query_time=10;" |
|
||||
mysql -e "set global log_queries_not_using_indexes = 'OFF';" |
|
||||
#sed -i "/slow-query-log/d" /etc/mysql/my.cnf |
|
||||
#sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf |
|
||||
#sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf |
|
||||
else |
|
||||
# Lets disable MySQL restart trigger |
|
||||
#EE_DEBUG_MYSQL="" |
|
||||
ee_lib_echo "MySQL slow log already disable" |
|
||||
fi |
|
||||
} |
|
Loading…
Reference in new issue