MySQL Slow log parsing script

Source: Internet
Author: User

#!/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.