Created
September 9, 2016 11:11
-
-
Save bwangelme/fd63f6ad85f665ff4ac185d07f52b8fb to your computer and use it in GitHub Desktop.
MySQL基准测试记录环境的脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#History: | |
# Michael Sep,09,2016 | |
#Program: | |
# | |
INTERVAl=5 | |
PREFIX=$INTERVAl-sec-status | |
RUNFILE="/tmp/mysql-test-running" | |
mysql -e 'SHOW GLOBAL VARIABLES' -u root -pdeepin >> mysql-variables | |
while test -e $RUNFILE;do | |
file=$(date +%F_%I) | |
sleep=$(date +%s.%N | awk "{ print $INTERVAl - (\$1 % $INTERVAl)}") | |
sleep $sleep | |
ts="$(date +"TS %s.%N %F %T")" | |
loadavg="$(uptime)" | |
echo "$ts $loadavg" >> $PREFIX-${file}-status | |
mysql -e 'SHOW GLOBAL STATUS' -u root -pdeepin >> $PREFIX-${file}-status & | |
echo "$ts $loadavg" -u root -pdeepin >> $PREFIX-${file}-innodbstatus | |
mysql -e 'SHOW ENGINE INNODB STATUS\G' -u root -pdeepin >> $PREFIX-${file}-innodbstatus & | |
echo "$ts $loadavg" -u root -pdeepin >> $PREFIX-${file}-processlist | |
mysql -e 'SHOW FULL PROCESSLIST\G' -u root -pdeepin >> $PREFIX-${file}-processlist & | |
echo $ts | |
done | |
echo "Exiting beause $RUNFILE does not exist." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment