脚本整理:监控mysql的show processlist脚本-雪洁之家

监控mysql的show processlist脚本

#!/bin/sh
 
username=
passwd=
host=
date=`date +%Y%m%d`
log_dir=/data/logs/process_list/
 
 
n=`mysqladmin processlist -u$username -p$passwd -h$host| wc -l`
date_time=`date +%Y%m%d[%H:%M:%S]`
echo "-----------------------------------------------------------------------------" >>$log_dir$date.log
echo "Time:"$date_time >>$log_dir$date.log
echo "连接数:"$n >>$log_dir$date.log
if [ "$n" -gt 10 ];then
    IFS=$'n' #
    for line in `mysqladmin processlist -u$username -p$passwd -h$host`
    do
    echo $line >>$log_dir$date.log
    done
fi

存储日志结果如下:


by 雪洁 2018-07-24 06:19:27 88 views
我来说几句

相关文章