From f689f0e9e1f81e06c557802bb701481d94bdac57 Mon Sep 17 00:00:00 2001 From: Tony Garcia Date: Sat, 18 Jul 2020 17:50:51 -0500 Subject: [PATCH 1/2] Add USEMYSQLFULLPROCESSLIST option to mysql plugin --- CHANGELOG.md | 1 + src/core/mysql | 21 ++++++++++++++------- src/recap | 6 ++++++ src/recap.conf | 14 ++++++++++---- src/recap.conf.5 | 10 ++++++++-- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8326b39..381501d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - - Modify iotop default [#218][218] - Add plugin cli support to `recap` [#217][217] +- Add USEMYSQLFULLPROCESSLIST option to mysql plugin [#231][231] ## [2.1.0] - 2019-04-12 - Remove signal `17` in `recaplog` [(#208)][208] diff --git a/src/core/mysql b/src/core/mysql index 4067ab5..0d07ab1 100644 --- a/src/core/mysql +++ b/src/core/mysql @@ -94,11 +94,18 @@ print_mysql_innodb_status() { log INFO "Ended 'mysql innodb' report" } -# Print the output of "mysqladmin processlist" to the mysql file +# Print the output of "mysqladmin [full] processlist" to the mysql file print_mysql_procs() { - log INFO "Starting 'mysql processlist' report - ${LOGFILE##*/}" local LOGFILE="$1" local MYCNF="$2" + local FULL="$3" + local MY_V="" + local MY_PL="processlist" + if [[ -n "${FULL}" ]]; then + MY_PL="full processlist" + MY_V="-v" + fi + log INFO "Starting 'mysql ${MY_PL}' report - ${LOGFILE##*/}" local PLESK_FILE="/etc/psa/.psa.shadow" if [[ -r "${PLESK_FILE}" ]]; then echo "MySQL (plesk) processes" >> "${LOGFILE}" @@ -106,7 +113,7 @@ print_mysql_procs() { mysqladmin \ -uadmin \ -p$( cat "${PLESK_FILE}" ) \ - -v processlist \ + ${MY_V} processlist \ --connect-timeout=5 \ >> "${LOGFILE}" fi @@ -115,7 +122,7 @@ print_mysql_procs() { -uadmin \ -p$( cat "${PLESK_FILE}" ) \ --connect-timeout=5 \ - -e "show full processlist\G" \ + -e "show ${MY_PL}\G" \ >> "${LOGFILE}" fi else @@ -123,17 +130,17 @@ print_mysql_procs() { if [[ ${MYSQL_PROCESS_LIST} == "table" ]]; then mysqladmin \ --defaults-file="${MYCNF}" \ - -v processlist \ + ${MY_V} processlist \ --connect-timeout=5 \ >> "${LOGFILE}" elif [[ ${MYSQL_PROCESS_LIST,,} == "vertical" ]]; then mysql \ --defaults-file="${MYCNF}" \ --connect-timeout=5 \ - -e "show full processlist\G" \ + -e "show ${MY_PL}\G" \ >> "${LOGFILE}" fi fi print_blankline "${LOGFILE}" - log INFO "Ended 'mysql processlist' report" + log INFO "Ended 'mysql ${MY_PL}' report" } diff --git a/src/recap b/src/recap index 7c8b200..79d717e 100755 --- a/src/recap +++ b/src/recap @@ -99,10 +99,12 @@ declare -r default_DOTMYDOTCNF="/root/.my.cnf" declare -r default_MYSQL_PROCESS_LIST="table" declare -r default_USEINNODB="no" declare -r default_USEMYSQLPROCESSLIST="no" +declare -r default_USEMYSQLFULLPROCESSLIST="no" DOTMYDOTCNF="${default_DOTMYDOTCNF}" MYSQL_PROCESS_LIST="${default_MYSQL_PROCESS_LIST}" USEINNODB="${default_USEINNODB}" USEMYSQLPROCESSLIST="${default_USEMYSQLPROCESSLIST}" +USEMYSQLFULLPROCESSLIST="${default_USEMYSQLFULLPROCESSLIST}" # Default command options(can be overridden in config file) declare -r default_OPTS_DF="-x nfs" @@ -374,6 +376,10 @@ run_mysql_report() { print_blankline "${ITEM_FILE}" print_mysql_procs "${ITEM_FILE}" "${MYCNF}" fi + if [[ "${USEMYSQLFULLPROCESSLIST,,}" == "yes" ]]; then + print_blankline "${ITEM_FILE}" + print_mysql_procs "${ITEM_FILE}" "${MYCNF}" "FULL" + fi if [[ "${USEINNODB,,}" == "yes" ]]; then # send df -h output to output file print_blankline "${ITEM_FILE}" diff --git a/src/recap.conf b/src/recap.conf index 056d082..869b6ab 100644 --- a/src/recap.conf +++ b/src/recap.conf @@ -59,7 +59,7 @@ ## Report: mysql # USEMYSQL - Generates logs from "mysqladmin status" # makes use of DOTMYDOTCNF. -# Required by: USEMYSQLPROCESSLIST, USEINNODB +# Required by: USEMYSQLPROCESSLIST, USEMYSQLFULLPROCESSLIST, USEINNODB # Example, to enable: USEMYSQL="yes" #USEMYSQL="no" @@ -69,6 +69,12 @@ # Example, to enable: USEMYSQLPROCESSLIST="yes" #USEMYSQLPROCESSLIST="no" +# USEMYSQLFULLPROCESSLIST - Generates logs from "mysqladmin -v processlist" +# Makes use of DOTMYDOTCNF and MYSQL_PROCESS_LIST +# requires: USEMYSQL +# Example, to enable: USEMYSQLFULLPROCESSLIST="yes" +#USEMYSQLFULLPROCESSLIST="no" + # USEINNODB - Generates logs from "mysql show engine innodb status" # Makes use of DOTMYDOTCNF # requires: USEMYSQL @@ -145,9 +151,9 @@ #DOTMYDOTCNF="/root/.my.cnf" # MYSQL_PROCESS_LIST - Format to display MySQL process list, options are -# "table" or "vertical". This requires that USEMYSQLPROCESSLIST be set -# "yes". -# Required by: USEMYSQLPROCESSLIST +# "table" or "vertical". This requires that USEMYSQLPROCESSLIST and/or +# USEMYSQLFULLPROCESSLIST set to "yes". +# Required by: USEMYSQLPROCESSLIST, USEMYSQLFULLPROCESSLIST # Example, generate vertical output: MYSQL_PROCESS_LIST="vertical" #MYSQL_PROCESS_LIST="table" diff --git a/src/recap.conf.5 b/src/recap.conf.5 index a22dd81..f5cd922 100644 --- a/src/recap.conf.5 +++ b/src/recap.conf.5 @@ -118,6 +118,12 @@ Can be set to yes or no depending on whether or not the output of "mysqladmin pr .IR ${BASEDIR}/mysql.log (default: no) +.IP \fBUSEMYSQLFULLPROCESSLIST\fR +.br +Can be set to yes or no depending on whether or not the output of "mysqladmin -v processlist" command should be recorded. This report requires that USEMYSQL be set to "yes". This option makes use of MYSQL_PROCESS_LIST, to produce the output vertical or in a table. This output is written in +.IR ${BASEDIR}/mysql.log +(default: no) + .IP \fBUSEINNODB\fR .br Can be set to yes or no depending on whether or not the output of "mysql show engine innodb status" and other variables(pid_files, tmpdir) command should be recorded. This report requires that USEMYSQL be set to "yes". This output is written in @@ -131,12 +137,12 @@ Options used by the tools generating the reports .IP \fBDOTMYDOTCNF\fR .br -Option required by USEMYSQL, USEMYSQLPROCESSLIST, USEINNODB, defines the path to the mysql client configuration file. +Option required by USEMYSQL, USEMYSQLPROCESSLIST, USEMYSQLFULLPROCESSLIST, USEINNODB, defines the path to the mysql client configuration file. (default: "/root/.my.cnf") .IP \fBMYSQL_PROCESS_LIST\fR .br -Format to display MySQL process list, options are "table" or "vertical". This requires that USEMYSQLPROCESSLIST be set "yes". +Format to display MySQL process list, options are "table" or "vertical". This requires that USEMYSQLPROCESSLIST and/or USEMYSQLFULLPROCESSLIST to be set to "yes". (default: table). .IP \fBOPTS_LINKS\fR From cf057d77fe7af34fa8ce9d96fac1fe3f197eb7ea Mon Sep 17 00:00:00 2001 From: Tony Garcia Date: Fri, 12 Aug 2022 08:36:04 -0500 Subject: [PATCH 2/2] Add priority to USEMYSQLFULLPROCESSLIST --- src/core/mysql | 2 +- src/recap | 7 +++---- src/recap.conf.5 | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/mysql b/src/core/mysql index 0d07ab1..d698af1 100644 --- a/src/core/mysql +++ b/src/core/mysql @@ -94,7 +94,7 @@ print_mysql_innodb_status() { log INFO "Ended 'mysql innodb' report" } -# Print the output of "mysqladmin [full] processlist" to the mysql file +# Print the output of "mysql [full] processlist" to the mysql file print_mysql_procs() { local LOGFILE="$1" local MYCNF="$2" diff --git a/src/recap b/src/recap index 79d717e..c8f8321 100755 --- a/src/recap +++ b/src/recap @@ -372,13 +372,12 @@ run_mysql_report() { print_mysql "${ITEM_FILE}" "${MYCNF}" # check to see if the optional mysql process list should be generated - if [[ "${USEMYSQLPROCESSLIST,,}" == "yes" ]]; then - print_blankline "${ITEM_FILE}" - print_mysql_procs "${ITEM_FILE}" "${MYCNF}" - fi if [[ "${USEMYSQLFULLPROCESSLIST,,}" == "yes" ]]; then print_blankline "${ITEM_FILE}" print_mysql_procs "${ITEM_FILE}" "${MYCNF}" "FULL" + elif [[ "${USEMYSQLPROCESSLIST,,}" == "yes" ]]; then + print_blankline "${ITEM_FILE}" + print_mysql_procs "${ITEM_FILE}" "${MYCNF}" fi if [[ "${USEINNODB,,}" == "yes" ]]; then # send df -h output to output file diff --git a/src/recap.conf.5 b/src/recap.conf.5 index f5cd922..755b48d 100644 --- a/src/recap.conf.5 +++ b/src/recap.conf.5 @@ -120,7 +120,7 @@ Can be set to yes or no depending on whether or not the output of "mysqladmin pr .IP \fBUSEMYSQLFULLPROCESSLIST\fR .br -Can be set to yes or no depending on whether or not the output of "mysqladmin -v processlist" command should be recorded. This report requires that USEMYSQL be set to "yes". This option makes use of MYSQL_PROCESS_LIST, to produce the output vertical or in a table. This output is written in +Can be set to yes or no depending on whether or not the output of "mysqladmin -v processlist" command should be recorded. This report requires that USEMYSQL be set to "yes". This option takes priority over USEMYSQLPROCESSLIST. This option makes use of MYSQL_PROCESS_LIST, to produce the output vertical or in a table. This output is written in .IR ${BASEDIR}/mysql.log (default: no)