检测mysql sleep 进程数,超过10个就k掉
#!/bin/sh 注:这个脚本运行后会每五秒去检测一次 mysql 的sleep进程数 while : do n=`/usr/bin/mysqladmin processlist | grep -i sleep | wc -l` date=`date +%Y%m%d\[%H:%M:%S]` echo $n if [ "$n" -gt 10 ] then for i in `/usr/bin/mysqladmin processlist | grep -i sleep | awk '{print $2}'` do /usr/bin/mysqladmin kill $i done echo "sleep is too many i killed it" >> /tmp/sleep.log echo "$date : $n" >> /tmp/sleep.log fi sleep 5 done