MySQL master-slave status monitoring script alarm script

Source: Internet
Author: User

#! /bin/bash

Mysqlport= ' NETSTAT-ANTLP |grep "LISTEN" ' |grep "3306" |awk-f[: ""]+ ' {print $4} '

Mysqlip = ' ifconfig eth0 ' |grep "inet addr" |awk-f[: ""]+ ' {print $4} '

STATUS = $ (/usr/local/mysql/bin/mysql-uroot-ppassword-e "show slave Status\g" |grep-i "Running")

io_env = ' echo $STATUS |grep IO |awk ' {print $} '

sql_env = ' echo $STATUS |grep SQL |awk ' {print $} '

If ["$ mysqlport = =" 3306 ""]

Then

echo "MySQL is runing"

Else

Mail-s "warn! Server: $MYSQLIP MySQL is down " [email protected]

Fi

If ["$IO _env" = "yes"-a "$SQL _env" = "yes"]

Then

echo "Slave is running!"

Else

echo "##### $date # # # # # #" >>/tmp/check_mysql_slave.log

echo "SLAVE is not runing!" >>/data/data/chek_mysql_slave.log

Mail-s "warn!" $MYSQLIP _replicate_error " [email protected] <</tmp/check_mysql_slave.log

Fi

Crontal-l

*/15 * * * */bin/sh/root/mysql.sh

This article is from the "11324462" blog, please be sure to keep this source http://11334462.blog.51cto.com/11324462/1752361

MySQL master-slave status monitoring script alarm 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.