#!/bin/sh
MYSQL_PW=mysqlpass
logdir=/root/mysql-log
logfile=$logdir/thread.log
THR_MAX=50
[ ! -d $logdir ] && mkdir -p $logdir
while :;
do
date >>$logfile
thr=`mysql -uroot -p$MYSQL_PW -e "status"|grep Threads|awk '{print $2}'`
echo -n "the process is :$thr " >>$logfile
[ $thr -gt $THR_MAX ] && mysql -uroot -p$MYSQL_PW -e "show full processlist" >$logdir/`date +%y%m%d-%H%M`-proc.log
echo "" >>$logfile
echo "===========================================" >>$logfile
sleep 30
done
MYSQL_PW=mysqlpass
logdir=/root/mysql-log
logfile=$logdir/thread.log
THR_MAX=50
[ ! -d $logdir ] && mkdir -p $logdir
while :;
do
date >>$logfile
thr=`mysql -uroot -p$MYSQL_PW -e "status"|grep Threads|awk '{print $2}'`
echo -n "the process is :$thr " >>$logfile
[ $thr -gt $THR_MAX ] && mysql -uroot -p$MYSQL_PW -e "show full processlist" >$logdir/`date +%y%m%d-%H%M`-proc.log
echo "" >>$logfile
echo "===========================================" >>$logfile
sleep 30
done
编辑回复