Move code to get InnoDB status into its own sub.

This commit is contained in:
Daniel Nichter
2013-03-12 15:08:25 -06:00
parent 177c2aaef7
commit 7f728acddd
2 changed files with 54 additions and 38 deletions

View File

@@ -715,27 +715,14 @@ collect() {
log "Could not find the MySQL error log" log "Could not find the MySQL error log"
fi fi
local innostat="SHOW /*!40100 ENGINE*/ INNODB STATUS\G"
if [ "${mysql_version}" '>' "5.1" ]; then if [ "${mysql_version}" '>' "5.1" ]; then
local mutex="SHOW ENGINE INNODB MUTEX" local mutex="SHOW ENGINE INNODB MUTEX"
else else
local mutex="SHOW MUTEX STATUS" local mutex="SHOW MUTEX STATUS"
fi fi
( innodb_status 1
$CMD_MYSQL $EXT_ARGV -e "$innostat" >> "$d/$p-innodbstatus1" $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status1" &
grep "END OF INNODB" "$d/$p-innodbstatus1" >/dev/null || { open_tables >> "$d/$p-opentables1" &
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted > /dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus1"
break
}
}
done
}
) &
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status1" &
open_tables >> "$d/$p-opentables1" &
local tcpdump_pid="" local tcpdump_pid=""
if [ "$CMD_TCPDUMP" -a "$OPT_COLLECT_TCPDUMP" ]; then if [ "$CMD_TCPDUMP" -a "$OPT_COLLECT_TCPDUMP" ]; then
@@ -873,9 +860,9 @@ collect() {
[ "$mysqld_pid" ] && kill -s 18 $mysqld_pid [ "$mysqld_pid" ] && kill -s 18 $mysqld_pid
fi fi
$CMD_MYSQL $EXT_ARGV -e "$innostat" >> "$d/$p-innodbstatus2" & innodb_status 2
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" & $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" &
open_tables >> "$d/$p-opentables2" & open_tables >> "$d/$p-opentables2" &
kill $mysqladmin_pid kill $mysqladmin_pid
[ "$tail_error_log_pid" ] && kill $tail_error_log_pid [ "$tail_error_log_pid" ] && kill $tail_error_log_pid
@@ -949,6 +936,27 @@ transactions() {
$CMD_MYSQL $EXT_ARGV -e "SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS\G" $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS\G"
} }
innodb_status() {
local n=$1
local innostat=""
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
}
done
fi
}
}
# ########################################################################### # ###########################################################################
# End collect package # End collect package
# ########################################################################### # ###########################################################################

View File

@@ -103,27 +103,14 @@ collect() {
# Get a sample of these right away, so we can get these without interaction # Get a sample of these right away, so we can get these without interaction
# with the other commands we're about to run. # with the other commands we're about to run.
local innostat="SHOW /*!40100 ENGINE*/ INNODB STATUS\G"
if [ "${mysql_version}" '>' "5.1" ]; then if [ "${mysql_version}" '>' "5.1" ]; then
local mutex="SHOW ENGINE INNODB MUTEX" local mutex="SHOW ENGINE INNODB MUTEX"
else else
local mutex="SHOW MUTEX STATUS" local mutex="SHOW MUTEX STATUS"
fi fi
( innodb_status 1
$CMD_MYSQL $EXT_ARGV -e "$innostat" >> "$d/$p-innodbstatus1" $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status1" &
grep "END OF INNODB" "$d/$p-innodbstatus1" >/dev/null || { open_tables >> "$d/$p-opentables1" &
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted > /dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus1"
break
}
}
done
}
) &
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status1" &
open_tables >> "$d/$p-opentables1" &
# If TCP dumping is specified, start that on the server's port. # If TCP dumping is specified, start that on the server's port.
local tcpdump_pid="" local tcpdump_pid=""
@@ -284,9 +271,9 @@ collect() {
[ "$mysqld_pid" ] && kill -s 18 $mysqld_pid [ "$mysqld_pid" ] && kill -s 18 $mysqld_pid
fi fi
$CMD_MYSQL $EXT_ARGV -e "$innostat" >> "$d/$p-innodbstatus2" & innodb_status 2
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" & $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" &
open_tables >> "$d/$p-opentables2" & open_tables >> "$d/$p-opentables2" &
# Kill backgrounded tasks. # Kill backgrounded tasks.
kill $mysqladmin_pid kill $mysqladmin_pid
@@ -369,6 +356,27 @@ transactions() {
$CMD_MYSQL $EXT_ARGV -e "SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS\G" $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS\G"
} }
innodb_status() {
local n=$1
local innostat=""
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
}
done
fi
}
}
# ########################################################################### # ###########################################################################
# End collect package # End collect package
# ########################################################################### # ###########################################################################