标签:慢日志分析脚本
#!/bin/bash
# analysis the mysql slow log
# Writen by landline
#IPadd=`grep `hostname` /etc/hosts | awk -F‘ ‘ ‘END{print $1}‘ `
IPadd=`/sbin/ifconfig eth0 |grep Bcast |awk -F: ‘{print $2}‘|awk ‘{print $1}‘ `
serverday=`date -d ‘-1 day‘ +%Y-%m-%d`
nowday=`date "+%y%m%d"`
yestoday=`date -d ‘-1 day‘ +%y%m%d`
twoday=`date -d ‘-2 day‘ +%y%m%d`
awk -vs=$twoday -ve=$nowday ‘/^# Time:/{if(s<$(NF-1)&&$(NF-1)<e)P=1;else P=0}P‘ /data/mysql/data1/KXC-Iaround-ImAccount-MASTER-slow.log >/data//tomrrowslow.log
sleep 2
#cd /usr/local/mysql/bin
/usr/local/mysql/bin/mysqldumpslow -s c /data/tomrrowslow.log > /data/$IPadd\_master\_$yestoday.txt
#echo $IPadd > /data/161.txt
##ftp upload FTP上传 ##
/usr/bin/ftp -n<<!
open IP
user upload_log 4327st18
binary
cd /mysql_logs/slow_logs
cd $serverday
lcd /data
prompt
mput $IPadd\_master\_$yestoday.txt
close
bye
!
rm -f /data/tomrrowslow.log
rm -f /data/$IPadd\_master\_$yestoday.txt
本文出自 “运维工程师DBA之路” 博客,转载请与作者联系!
标签:慢日志分析脚本
原文地址:http://landline.blog.51cto.com/6065685/1576621