#!/bin/bash
# Analysis of the MySQL slow log
# Writen by Landline
#IPadd = ' grep ' hostname '/etc/hosts | Awk-f ' End{print $ '
Ipadd= '/sbin/ifconfig eth0 |grep bcast |awk-f: ' {print $ {} ' |awk ' {print '} '
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 upload # #
/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
This article is from the "Operation and maintenance Engineer DBA Road" blog, reprint please contact the author!
MySQL Slow log parsing script