MySQL monitor shell from library status

Source: Internet
Author: User

Monitor MySQL

Slave_io_running:

Slave_sql_running:

Status, no mail alarm

Recently found an e-mail tool, simple and easy to use sendEmail, installation-free personal feeling very useful

Reference: http://blog.chinaunix.net/uid-10697776-id-3185073.html

Vim slave.sh

Ideas:

Filter the values of slave_io_running && slave_sql_running. For no mail alarm, write log slave.log at the same time. Of course, you have to empty the log regularly (I'm doing more than 1152 lines per view of the log, emptying the log.) Also determine if there is no in the log

field, there is no emptying operation, easy to record the failure time)

Variable: test_time= recording time

Slave_io=slave_io_running: The state of

Slave_sql=slave_sql_running: The state of

Related: mysql-uuser-h ip-ppasswd-e "command" (do not log in to MySQL to execute MySQL command)


#!/bin/bashtest_time= ' date -d today + "%y%m%d--%h:%m:%s" ' slave_io= '/usr/local/bin/mysql - uroot -h 127.0.0.1  -e  "show slave status\g;" | grep slave_io_running|awk  ' {print $2} ' slave_sql= '/usr/local/bin/mysql -uroot -h  127.0.0.1  -e  "show slave status\g;" | grep slave_sql_running|sed -n  ' 1p ' |awk  ' {print $2} ' cat_log= ' cat /tmp/shell/ Slave/slave.log|wc -l ' if [ ${slave_io} = yes ]; then         echo  "Slave_io_running: yes" ${test_time} >> /tmp/shell /slave/slave.log else        echo  "Slave_IO_Running: No "${test_time} >> /tmp/shell/slave/slave.log        / Usr/local/sendemail/sendemail-v1.56/sendemail -f [email protected] -t [emaIl protected] -xp xxx -s smtp.163.com -xu xxx -u test -m  slave_io_running: no__${test_time}fi## #if  [ ${SLAVE_SQL} = Yes ];  then        echo  "Slave_sql_running: yes" ${TEST_TIME}  >> /tmp/shell/slave/slave.log else        echo  " Slave_sql_running: no "${test_time} >> /tmp/shell/slave/slave.log         /usr/local/sendemail/sendemail-v1.56/sendemail -f [email protected]  -t [email protected] -xp xxx -s smtp.163.com -xu xxx -u  test -m slave_sql_running: no__${test_time}fi## #cat  /tmp/shell/slave/slave.log|grep  noif [ $? != 0 ]; then#       echo  $?   if [ ${cat_log} -gt 1152 ];        then         echo  ""  > /tmp/shell/slave/slave.log    Fifi

Please give me more advice ~ ~ ~

This article is from the "share is a virtue" blog, please be sure to keep this source http://passers.blog.51cto.com/9686614/1587514

MySQL monitor shell from library status

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.