您的位置:首页 > 数据库 > MySQL

MySQL常用脚本

2018-08-27 14:58 405 查看

监控MySQL 事务数

#!/bin/bash
/usr/bin/mysqladmin -P3306 -uroot -h '' -p extended-status -i1 |awk 'BEGIN{local_switch=0;print "QPS   Commit Rollback   TPS    Threads_con Threads_run \n------------------------------------------------------- "}
$2 ~ /Queries$/            {q=$4-lq;lq=$4;}
$2 ~ /Com_commit$/         {c=$4-lc;lc=$4;}
$2 ~ /Com_rollback$/       {r=$4-lr;lr=$4;}
$2 ~ /Threads_connected$/  {tc=$4;}
$2 ~ /Threads_running$/    {tr=$4;
if(local_switch==0)
{local_switch=1; count=0}
else {
if(count>10)
{count=0;print "------------------------------------------------------- \nQPS   Commit Rollback   TPS    Threads_con Threads_run \n------------------------------------------------------- ";}
else{
count+=1;
printf "%-6d %-8d %-7d %-8d %-10d %d \n", q,c,r,c+r,tc,tr;
}
}
}'

查看非活跃会话

select * from information_schema.processlist where COMMAND !='Sleep';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ja 常用脚本