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