TPS for mysql computing within the specified time; tps for mysql computing

Source: Internet
Author: User

TPS for mysql computing within the specified time; tps for mysql computing

<Pre name = "code" class = "SQL"> if a friend leaves a message, you must monitor the TPS at AM for the specified time, write a 10-second TPS method. #! /Bin/bashexport black = '\ 033 [0m' export boldblack =' \ 033 [1; 0m' export red = '\ 033 [31m' export boldred =' \ 033 [1; 31m' export green = '\ 033 [32m' export boldgreen =' \ 033 [1; 32m' export yellow = '\ 033 [33m' export boldyellow =' \ 033 [1; 33m' export blue = '\ 033 [34m' export boldblue =' \ 033 [1; 34m' export magenta = '\ 033 [35m' export boldmagenta =' \ 033 [1; 35m' export cyan = '\ 033 [36m' export boldcyan =' \ 033 [1; 36m' export white = '\ 033 [37m' export boldwhite =' \ 033 [1; 37m' cecho () # -- Function to easliy print colored text -- ### Color-echo. # parameter $1 = message # parameter $2 = color {local default_msg = "No message passed. "message =$ {1:-$ default_msg} # If $1 is not input, the default value is default_msg.color =$ {2:-black} # If $1 is not input, the default value is black. case $ color inblack) printf "$ black"; boldblack) printf "$ boldblack"; red) printf "$ red"; boldred) printf "$ boldred ";; green) printf "$ green"; boldgreen) printf "$ boldgreen"; yellow) printf "$ yellow"; boldyellow) printf "$ boldyellow"; blue) printf "$ blue"; boldblue) printf "$ boldblue"; magenta) printf "$ magenta"; boldmagenta) printf "$ boldmagenta"; cyan) printf "$ cyan"; boldcyan) printf "$ boldcyan"; white) printf "$ white"; boldwhite) printf "$ boldwhite ";; esac printf "% s \ n" "$ message" tput sgr0 # tput sgr0 restores the default value printf "$ black" return} cechon () # Color-echo. # parameter 1 $1 = message # parameter 2 $2 = color {local default_msg = "No message passed. "# doesn' t really need to be a local variable. message =$ {1:-$ default_msg} # If $1 is not input, the default value is default_msg.color =$ {2:-black} # If $1 is not input, the default value is black. case $ color inblack) printf "$ black"; boldblack) printf "$ boldblack"; red) printf "$ red"; boldred) printf "$ boldred ";; green) printf "$ green"; boldgreen) printf "$ boldgreen"; yellow) printf "$ yellow"; boldyellow) printf "$ boldyellow"; blue) printf "$ blue"; boldblue) printf "$ boldblue"; magenta) printf "$ magenta"; boldmagenta) printf "$ boldmagenta"; cyan) printf "$ cyan"; boldcyan) printf "$ boldcyan"; white) printf "$ white"; boldwhite) printf "$ boldwhite ";; esac printf "% s" "$ message" tput sgr0 # tput sgr0 restores the default value printf "$ black" return} # set mysql evnMYSQL_USER = root # mysql username MYSQL_PASS = '2016' # mysql logon User Password MYSQL_HOST = localhost # TPS01 (transaction volume during the interval) #### TPS = (Com_commit + Com_rollback)/seconds ######## mysql> show global status like 'com _ insert '; ####### mysql> show global status like 'com _ Update'; ####### mysql> show global status like 'com _ delete '; #### sleep_time = 10tps_01 = "show global status where Variable_name in ('com _ insert '); "tps_02 =" show global status where Variable_name in ('com _ Update'); "tps_03 =" show global status where Variable_name in ('com _ delete '); "tps_re01 =" tpsre01. 'date between "tps_re02 =" tpsre02. 'date between "tps_re03 =" tpsre03. 'date between "mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER}-p $ {MYSQL_PASS}-e "$ {tps_01}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re01} mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER }-p $ {MYSQL_PASS}-e "$ {tps_02}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re02} mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER}-p $ {MYSQL_PASS}-e "$ {tps_03}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re03} tps_01_re = 'cat $ {tps_re01} 'tps _ 02_re = 'cat $ {tps_re02} 'tps _ 03_re = 'cat $ {tps_re03}' tps _ sum_now = 'awk' BEGIN {print '$ {tps_01_re} '+' $ {tps_02_re} '+' $ {tps_03_re} '# shell does not support floating-point operations rm-rf $ {tps_re01} rm-rf $ {tps_re02} rm by default -rf $ {tps_re03} echo "obtaining TPS value: "sleep $ {sleep_time} tps_021 =" show global status where Variable_name in ('com _ insert '); "tps_022 =" show global status where Variable_name in ('com _ Update'); "tps_023 =" show global status where Variable_name in ('com _ delete '); "tps_re021 =" tpsre021. 'date ready "tps_re022 =" tpsre022. 'date ready "tps_re023 =" tpsre023. 'date ready "mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER}-p $ {MYSQL_PASS}-e "$ {tps_021}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re021} mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER }-p $ {MYSQL_PASS}-e "$ {tps_022}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re022} mysql-h $ {MYSQL_HOST}-u $ {MYSQL_USER}-p $ {MYSQL_PASS}-e "$ {tps_023}" | grep-v Variable_name \ | cut-f 2 >$ {tps_re023} tps_021_re = 'cat $ {tps_re021} 'tps _ 022_re = 'cat $ {tps_re022} 'tps _ 023_re = 'cat $ {tps_re023}' tps _ sum_new = 'awk' BEGIN {print '$ {tps_021_re} '+' $ {tps_022_re} '+' $ {tps_023_re} 'tps _ sum_diff = 'awk' BEGIN {print' $ {tps_sum_new} '-' $ {tps_sum_now} '} ''tps _ avg = 'awk' BEGIN {print' $ {tps_sum_diff} '/' $ {sleep_time} '} ''# shell does not support floating-point operations by default. cechon" the last $ sleep_time seconds, TPS is: $ {tps_avg} "redecho" "echo" "rm-rf $ {tps_re021} rm-rf $ {tps_re022} rm-rf ${tps_re023 }######## #### the running result is obtaining the TPS value: within the last 10 seconds, TPS is: 0.9


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.