SQL_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默认不支持浮点运算
rm -rf ${tps_re01}
rm -rf ${tps_re02}
rm -rf ${tps_re03}
echo "正在获取TPS值:"
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 +%Y%m%d%H%M%S`.txt"
tps_re022="tpsre022.`date +%Y%m%d%H%M%S`.txt"
tps_re023="tpsre023.`date +%Y%m%d%H%M%S`.txt"
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默认不支持浮点运算
cechon "Within the last $sleep_time seconds,TPS is: ${tps_avg} " red
echo " "
echo " "
rm -rf ${tps_re021}
rm -rf ${tps_re022}
rm -rf ${tps_re023}
############运行结果
正在获取TPS值:
Within the last 10 seconds,TPS is: 0.9
|